This is a migrated thread and some comments may be shown as answers.

Get Bytes Rad Upload Again

3 Answers 161 Views
Upload
This is a migrated thread and some comments may be shown as answers.
Babatunde Ogidan
Top achievements
Rank 1
Babatunde Ogidan asked on 07 Apr 2010, 01:06 PM
Hi i'm trying to get bytes from the radupload. i went through the thread "How can I get Byte[] file?"  started by Jan micheal. I got it working but i have problem. I cant  get the bytes from the client side even, my problem is that the returnedData is empty, i mean  et.HandlerDate.CustomData has no items cos when i used a break point and stepped through its count was zero. so please help ASAP

//Client Side

{

............

   private void radFileUploder_UploadFinished(object sender, Telerik.Windows.Controls.FileUploadedEventArgs et)
        {       
         //  string dataInStringFmt;
           var returnedData = et.HandlerData.CustomData["imgLastChunkData"];       
            // do something with returnedData
        }
...................

}

// Server Side

 

namespace XceedAdminister.Service
{
    public class imgHandler : Telerik.Windows.RadUploadHandler
    {      
        public override Dictionary<string, object> GetAssociatedData()
        {
            Dictionary<string, object> dict = base.GetAssociatedData();
            String buffer = this.Request.Form[Telerik.Windows.Controls.RadUploadConstants.ParamNameData];
            dict.Add("imgLastChunkData", buffer);
            return dict;          
        }

        int i = 0;

        public override void ProcessStream()
        {           
            i = i + 1;

             byte[] buffer = Convert.FromBase64String(Request.Form[RadUploadConstants.ParamNameData]);
            this.AddReturnParam(RadUploadConstants.ParamNameAssociatedData, "");
            this.AddReturnParam(RadUploadConstants.ParamNameFinalFileRequest, this.IsFinalFileRequest());
            this.AddReturnParam(RadUploadConstants.ParamNameSuccess, true); // or false if something fails
            this.AddReturnParam(RadUploadConstants.ParamNameMessage, "");// or add an error message if it is needed
            string fileName = this.Request.Form[RadUploadConstants.ParamNameFileName];
            string filePath = this.GetFilePath(fileName);
            this.AddReturnParam(RadUploadConstants.ParamNameFileIdent, filePath);
            this.AddReturnParam(RadUploadConstants.ParamNameFileName, fileName);
            this.AddReturnParam(RadUploadConstants.ParamNameFilePath, filePath); 

        }

    }
}

3 Answers, 1 is accepted

Sort by
0
Accepted
Ivan
Telerik team
answered on 07 Apr 2010, 03:44 PM
Hi Babatunde,

Thank you for contacting us.

There are some issues I would like to point to:
  • Client side:
    Check the radFileUploder_UploadFinished handler to handle the FileUploaded event. For example your Xaml-code should seems like the code below:
     
    <telerik:RadUpload
        FileUploaded="radFileUploder_UploadFinished"
     
  •  Server side:
    • The GetAssociatedData method looks OK.
    • About the ProcessStream method:
      • This method is the backbone of the request-processing mechanism.
      • If it is overridden all its code have to be copied (not only the returned parameters).
      • After previewing the example implementation of this method we can suggest that you should rely on the original one, i.e. just comment your code.
    After all, your server side code should look like:
     
    namespace XceedAdminister.Service
    {
        public class imgHandler : Telerik.Windows.RadUploadHandler
        {
            public override Dictionary<string, object> GetAssociatedData()
            {
                Dictionary<string, object> dict = base.GetAssociatedData();
                String buffer = this.Request.Form[RadUploadConstants.ParamNameData];
                dict.Add("imgLastChunkData", buffer);
                return dict;
            }
        }
    }
     

That's all. Please give it a try and let us know if you have other questions.

Kind regards,
Ivan
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Babatunde Ogidan
Top achievements
Rank 1
answered on 08 Apr 2010, 08:41 AM
Thanks a lot i got it working now. just deleted the process stream method that i had overwritten earlier in the handler. 
0
Ivan
Telerik team
answered on 08 Apr 2010, 10:25 AM
Hi Babatunde Ogidan,

What about your Upload Handler. Especially I am interesting in the code of the ProcessStream method if it is still present. Please follow the points in our previous post. However if the upload is still not working could you open another Support Ticket in order to attach your project - here we will investigate and fix it.

Looking forward for your reply.

Greetings,
Ivan
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Upload
Asked by
Babatunde Ogidan
Top achievements
Rank 1
Answers by
Ivan
Telerik team
Babatunde Ogidan
Top achievements
Rank 1
Share this question
or