Splitting a file before downloading?

On a web page, is it possible to split large files into chunks before the file is uploaded to the server? For example, split a 10 MB file into 1 MB chunks and upload one chunk at a time, showing a progress bar?

JavaScript doesn't seem to have the ability to manipulate files, but what about Flash and Java applets?

This will need to work in IE6 +, Firefox and Chrome. Update : I forgot to mention that (a) we use Grails and (b) you need to run https for this.

+6
javascript flash applet file-upload
source share
4 answers

You can try plupload . It can be configured to check which runtime is available on the user side, be it Flash, Silverlight, HTML5, Gears, etc., And use what satisfies the required functions. Among other things, it supports image resizing ( on the user side, saving EXIF ​​data (!) ), Streaming and multi-page loading and fragmentation. Files can be split on the user side and sent to the chunk-by-chunk server handler (additional help is required on the server), so large files can be uploaded to the server with a maximum file size limit set to a value significantly smaller than their size, eg. And further.

Some of them support https, I believe some require testing. In any case, the developers there are very responsive these days. Therefore, you can at least try;)

+4
source share

The only option I know about this would be a signed Java applet.

Unsigned applets and Flash movies do not have access to the file system, so they cannot read the file data. Flash can download files, but most of them are handled by the built-in Flash implementation, and from what I remember, the contents of the file will never be displayed in your code.

+2
source share

There is no JavaScript solution for this choice of browsers. There is a File API , but as long as it works in new versions of Firefox and Chrome, this will not happen in IE (there are no signs of this in IE9 either).

In any case, reading the file locally and downloading it via XMLHttpRequest is inefficient, because XMLHttpRequest is not able to send pure binary, only Unicode text. You can encode the binary into text using base-64 (or, if you are really allocated, a custom 7-bit encoding), but it will be less efficient than regular file loading.

You can upload files using Flash (see SWFUpload et al.) Or even Java if you should ( Jumploader ... These days, I wouldn’t worry, since the prevalence of Flash is very high and the Java plugin continues to decline). You don't necessarily get low-level controls to split into pieces, but do you really need it? What for?

Another possible approach is to use a standard field for loading HTML files, and when sending, set an interval call to poll the server with XMLHttpRequest, asking him how far the file download is going. This requires a little work on the server to save the current load in a session or database so that another request can read it. It also means using a form parsing library that gives you a progress callback that most standard built-in languages ​​like PHP don't work.

No matter what you do, use the “progressive boost” approach, allowing browsers to return to simple HTML loading without support. Browsers usually have a download progress bar to download HTML files, it tends to be small and easily overlooked.

+1
source share

Do you specifically need two to be in X pieces? Or are you trying to solve the problem by downloading large files? (for example, cannot restart the download on the client side, failures on the server side when the entire file is downloaded and stored in memory immediately)

Search for streaming download components. It depends on what technologies you work with, which component you prefer jsp, asp.net, etc.

http://krystalware.com/Products/SlickUpload/ This is a server-side product. Here are some more pointers for different users. http://weblogs.asp.net/jgalloway/archive/2008/01/08/large-file-uploads- in-asp-net.aspx

some try to manage memory on the server, for example. so the whole huge file is not in memory at one time, some try to manage the experience on the client side.

0
source share

All Articles