Does it support resume?

Nov 16, 2009 at 4:39 PM

Can the uploader resume a file that was interrupted while in the process of uploading to the server?

Nov 16, 2009 at 7:16 PM

The provided implementation does not have explicit resume functionality, but it was built to eventually support such a feature.  Unfortunately I have some other higher priority projects at the moment, so I haven't gotten around to it.

If you are interested in having this feature sooner rather than later, let me know and I can point you to the relevant code that would need to be modified.

Nov 16, 2009 at 7:18 PM

I would be interested in implementing this -- that would be great if you could point me in the right direction.  Thanks.

Nov 17, 2009 at 7:07 PM

If you look at the provided http handler, Vci.FileUploader.UploaderControlHandler, the ProcessFile method is the main method that handles receiving each chunk of the file as it is uploaded.  You'll see that it simply opens a file on the server and appends the latest chunk.

So the general idea is that if the upload gets interrupted for some reason, you still have this file sitting on the server with the partial upload.  If the user tries to upload that file again, you'd want to check if you have a partial file that corresponds to their upload, and if so, figure out where it left off, and start from there rather than from the beginning of the file.

You will probably need to store some extra information with the file that is being built up on the server: what position are you at (though you may be able to calculate this from the length of the temporary file), and a more unique identifier for the file (using the file name to determine if you have an existing incomplete upload is probably not sufficient).  I don't know what the best way to do this would be -- maybe compute a hash value for the file before uploading, and send that over as an identifier.  You could just store these in an auxiliary temporary file.

If you look at the Vci.Silverlight.FileUploader.HttpFileUploader class, this is the silverlight object that sends data to the above-mentioned http handler.  The basic concept is that it repeatedly calls StartUpload to send each chunk.  You'll probably need to modify this to send an initial request to the server to check if there is a partial upload already present for the file that is being uploaded.  If so, you can use this to determine where to start reading data -- if you look in WriteToStreamCallback, you'll see how it is setting the position in the file stream for sending each chunk.

Let me know if that is enough detail to get you started.

Apr 16, 2010 at 3:42 PM


I really like this control. The only thing i miss is better fault-tolerance. I would like to retry last chunk transmit on WebException rather than bubbling it to the top and interrupting whole proccess.

Unfortunately, i'm not familiar with async webrequest/response. Could you post any suggestions?