Upload to Xaml codebehind instead of HttpHandler

6 posts, 0 answers
  1. Charles
    Charles avatar
    32 posts
    Member since:
    Mar 2008

    Posted 16 Feb 2009 Link to this post

    Hi,

    Is it possible for the Silverlight upload control to raise an event in the silverlight codebind while uploading data rather than serialiasing the data in the browser and sending to an ashx handler?

    The problem with the ashx handle implementation is there is no way to maintain a session context while each file is being uploaded. For example I initialise an object in the handler between IsNewFileRequest() call then attempt to read from it on subsequent requests.

    Thanks
  2. Ivan
    Admin
    Ivan avatar
    519 posts

    Posted 16 Feb 2009 Link to this post

    Hi Charles,

    Could you please go into some more details about what exactly you are up to? This information will help us provide more to-the-point reply.

    All the best,
    Ivan
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. DevCraft banner
  4. Charles
    Charles avatar
    32 posts
    Member since:
    Mar 2008

    Posted 16 Feb 2009 Link to this post

    I am attempting to implement upload to a cloud server via REST - the details of this are not important. But what is, is that I must maintain a Http Connection in the handler while the file is being uploaded.

    Currently I override the ProcessStream method and setup my connection upon the file starting

     

    Public Overrides Sub ProcessStream()

     

    If

     

    (IsNewFileRequest()) Then
    '//Setup connection
    End If

     

     

    Dim bData As Byte() = Convert.FromBase64String(Context.Request.Form(Telerik.Windows.Controls.RadUploadConstants.ParamNameData))

     

    Append(bData)

     

     

    If (IsFinalFileRequest()) Then

     

    Finish()

     

    End If
    End Sub

    My Finish method then closes the stream and asks for the response back from the cloud service.

    The problem I am having is that it appears the handler is requested after each chunk of data is sent from the silverlight control - therefore my objects are lost and the stream cannot be appended to.

    My thoughts were that maybe there was an event on the silverlight control like UploadDataSent etc that passes the data as base64 or bytes and that the class is initialised once per upload request (not per chunk) so that any objects initialised are not disposed - that would be the ideal solution for me.

    Do you have any thoughts on this?

    Thanks

     

  5. Ivan
    Admin
    Ivan avatar
    519 posts

    Posted 17 Feb 2009 Link to this post

    Hello Charles,

    Thank you for sending this clarifying information.

    We have recently implemented the ChunkTag mechanism in order to cover a similar scenario - please preview this thread and let me know whether this is appropriate for you.

    Currently, you can rely on the fact that all chunks are  subsequently uploaded and at the moment when IsFinalFileRequest is true all the file content will be present - the only extra action you should take is to remove the file after resending it to the cloud server.

    Sincerely yours,
    Ivan
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  6. Charles
    Charles avatar
    32 posts
    Member since:
    Mar 2008

    Posted 19 Feb 2009 Link to this post

    Thanks for the reply.

    Unfortunately this is not quite what i'm looking for.

    All the ChunkTag property enables you to do is store some kind of identifer so that next time round you can use it for appending to the file/database/whatever.

    The problem is that the silverlight upload control creates a new request to the http ashx handler passing the data chunk is base64 format. If you were relying on a service which you must write the data chunk to a stream this is not possible in the way you've implemented it.

    For example, if you wanted to upload the file from the silverlight control -> ashx handler -> then to an FTP server. The only way to do this is to open a connection to the file on the FTP on every new request to the handler file - which is obviously highly inefficient.

    One solution to this problem, as you've rightly suggested, is that to wait until the silverlight upload control has uploaded ALL the data to the server THEN forward that data onto wherever. What happens if I was uploading a 10/100mb or 1gb file? I would have to wait to upload the file to the server, then wait AGAIN to forward the data to its final destination.

    I would have expected Telerik to have thought of this, especially as the Silverlight controls have just been released. The increasing amount of online storage systems such as Amazon S3, Mosso Files etc only work over HTTP with various API procedures but basically work in streams to submit data.

    Referring to my original post, is it not possible to simply add another event on the Silverlight Upload Control such as FileUploading?

    Regards

  7. Ivan
    Admin
    Ivan avatar
    519 posts

    Posted 20 Feb 2009 Link to this post

    Hello Charles,

    Thank for the clarification.

    You are correct to expect that from the Upload component. This is with highest priority in our list of features that we want to improve for RadUpload after the Q1 release.

    The feature will be implemented with the SP1 right after the Q1 release.

    Your telerik points has been updated.

    Kind regards,
    Ivan
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Back to Top
DevCraft banner