views:

368

answers:

2

I have a desktop application that needs to upload files to a webserver.

The protocol is HTTPS.

I'm thinking I should write an ashx that will handle the uploads; sending 4k chunks at a time. With a response of ok each time. Is this a good algorithm?

What is the best algorithm for uploading from a desktop application to a webserver over HTTPS?

+3  A: 

How large of files are you looking to upload? As long as they're not huge (> 100 MB), you could generate a multipart MIME encoded upload (RFC 1867) from your application. This is the same format browsers use for uploads, so your handler would just pull the file from the Request.Files collection. Chunking isn't going to get you much unless you're uploading on a slow connection or uploading huge files.

Chris Hynes
+2  A: 

Chunking is likely to slow you down if you take the simplistic approach of sending the next packet only after the acknowledgement of the previous packet is received. This approach has proven to be slow (over networks with nontrivial latency). Try something that's directly supported by the webserver rather than rolling your own (such as the suggestion made by Chris Hynes: multipart MIME encoded upload).

jdigital
Do you have a reference for "proven to be slow?"
I don't have a reference at hand. There are two kinds of proofs for this, mathematical and "proven by experience", and both of these should be available if you look around. As a starting point, search for "sliding window protocol".
jdigital
Let the network handle that problem for you. You don't need to think about it.
Nathan
What Nathan is saying is that chunking and acknowledgements are already built into TCP. What's the point of recreating this? Is there some special requirement you haven't mentioned?
jdigital