Get Bytes Rad Upload Again

4 posts, 1 answers
  1. Babatunde Ogidan
    Babatunde Ogidan avatar
    2 posts
    Member since:
    Jan 2010

    Posted 07 Apr 2010 Link to this post

    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); 

            }

        }
    }

  2. Answer
    Ivan
    Admin
    Ivan avatar
    519 posts

    Posted 07 Apr 2010 Link to this post

    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.
  3. DevCraft banner
  4. Babatunde Ogidan
    Babatunde Ogidan avatar
    2 posts
    Member since:
    Jan 2010

    Posted 08 Apr 2010 Link to this post

    Thanks a lot i got it working now. just deleted the process stream method that i had overwritten earlier in the handler. 
  5. Ivan
    Admin
    Ivan avatar
    519 posts

    Posted 08 Apr 2010 Link to this post

    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.
Back to Top