0

I'm writing an uploader that has to be able to transmit files of any size (up to 30gigs) to the server.

My original intention was to write a java applet that would break the file up into pieces, send those to the server, and then reassemble them there.

However, someone has suggested that AJAX's XMLHttpRequest can do the job in conjunction with nsIFileInputStream (example here: https://developer.mozilla.org/en/using_xmlhttprequest#Sending_files_using_a_FormData_object ) and by using PUT instead of POST.

I'm worried about 2 things and can't seem to find the answer.

1) Will AJAX attempt to read the file into memory before sending it (that obviously would break the whole thing)

[EDIT] This http://www.codeproject.com/KB/ajax/AJAXFileUpload.aspx?msg=2329446 example explicitly states that they're using ActiveXObject because that DOESN'T load the file into memory... which suggests to me that XMLHttpRequest would load it into memory. I'm surprised I'm having such a hard time finding this info, to be honest.

2) How reliable is this approach. I realize that if the connection just dies the upload would have to resume from scratch, but realistically, how likely is it that using a standard cable connection with an upload throttle of about .5MB/s that a 30 gig file would arrive at the server?

Yevgeny Simkin
  • 27,946
  • 39
  • 137
  • 236

1 Answers1

1

I'm trying something similar using File Api and blob.slice, but it turned out to clock up memory on large files.. However, you could use Google Gears, which plays much better with large sliced files. It also doesnt cause errors with the slice order, which FileReader combined with XHR does frequently and randomly.

I do however find (generally) that uploading files via JavaScript is very unstable..

TecBrat
  • 3,643
  • 3
  • 28
  • 45
Fabdrol
  • 728
  • 1
  • 7
  • 20
  • yeah, the more I examine this, the more I'm inclined to think that this is not a workable approach. – Yevgeny Simkin Jan 21 '11 at 21:43
  • It probably will be, one day. Other options are using Flash, Silverlight or BrowserPlus. Gears seems to be abandoned in favor of HTML5, however, it's still supported until all browser have implemented it correctly. – Fabdrol Jan 23 '11 at 20:42
  • Oh, and BrowserPlus has some really nice options, like gzipping a file before uploading it. Should cut back the upload time greatly. However, I wouldn't recommend BP for single small files, it's a bit overkill in my opinion. A great option is PLupload, which chooses the plugin the user has installed. – Fabdrol Jan 23 '11 at 20:44