views:

44

answers:

3

The project is a servlet to which people can upload files via, at present, HTTP POST. This is accompanied by Web page(s) providing a front-end to trigger the upload. We have more or less complete control over the servlet, and the Web pages, but don't want to impose any restrictions on the client beyond being a reasonably modern browser with Javascript. No Java applets etc.

Files may potentially be large, and a possible use case is mobile devices on less reliable networks. Some people on the project are demanding the ability to resume an upload if the network connection goes down. I don't think this is possible with plain HTTP and Javascript in a browser, but I'd love to be proved wrong.

Any suggestions?

+1  A: 

With your current restrictions, no.

(There may be a tiny chance that using the HTML5 file api could be capable of doing this. Maybe someone more knowledgeable can comment because I usually cannot make heads or tails of technical specifications from the w3c : http://www.w3.org/TR/file-upload/ )

zaf
I haven't seen anything in HTML5 about having this ability.
David Murdoch
Updated my post with link. Check the 'The Blob Interface'. Could that be a possibility?
zaf
@zaf: it looks like it could be. Even still, relying on HTML5 isn't a great idea at the moment for obvious reasons :-)
Andy E
+1  A: 

Not with Plain Ol' JS. It doesn't have access to the file system, not even a file added to an input type=file control and so it cannot manipulate the data and upload via XHR instead.

You would have to look into a Flash or Java based alternative.

Andy E
if you (Pete) can get away with it...use a flash based solution. Java takes too long to initialize.
David Murdoch
A: 

Firefox 3.6 implements a FileReader interface, however it doesn't seem to support any form of skipping. Therefor, you would need to read the file and split it where you need it to resume.

This would not be especially useful for large file since you would probably crash the browser anyway because of the memory-allocation it would need.

https://developer.mozilla.org/en/DOM/FileReader

jishi