Solved

How to concurrently upload file chunks rather than sequentially

Posted on 2013-05-19
13
1,427 Views
Last Modified: 2013-05-20
Hello experts,
I'm using the jQuery file upload plugin (attached). How can I alter the script to upload the chunks concurrently? The code says there are settings to achieve this but, as you can see in my embedded image, my files still seem to be uploading sequentially. Please help. jQuery File Upload Plugin files
0
Comment
Question by:aristanoble
  • 7
  • 3
  • 3
13 Comments
 
LVL 44

Expert Comment

by:Rainer Jeschor
ID: 39179396
Hi,
which upload plugin are you using?
Attachment is missing.
Thanks.
Rainer
0
 
LVL 1

Author Comment

by:aristanoble
ID: 39179406
Ah, it looks like some files in the attachment are not valid for EE so the page is here: https://github.com/blueimp/jQuery-File-Upload and download here: https://github.com/blueimp/jQuery-File-Upload/archive/master.zip.

Also, through my testing I've learned that the plugin sends files concurrently but only when multiple files are selected; chunks are sent sequentially though I'd like to send them concurrently.
0
 
LVL 44

Expert Comment

by:Rainer Jeschor
ID: 39179432
Hi,
from the project owner:
https://github.com/blueimp/jQuery-File-Upload/issues/2188
this is not implemented / supported.
Sorry, HTH
Rainer
0
 
LVL 1

Author Comment

by:aristanoble
ID: 39179461
I know. Any reason why it can't be done; I know without a doubt in my mind that it can.
0
 
LVL 44

Expert Comment

by:Rainer Jeschor
ID: 39179522
Hi,
I think the reason is that then the author has to publish sample code for the server side processing. If file chunks can be sent in parallel, the receiving component must be able to cache each chunk to concatenate the pieces in the right order (assume that chunk three arrives before chunk one upload has been completed ...).
HTH
Rainer
0
 
LVL 82

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 500 total points
ID: 39179649
After reading this question, I did a little research on the subject.  To send them 'simultaneously', you have to make a separate connection for each file.  You could do this 'manually' by putting separate forms for each file on your page and clicking on each one in turn.  If you put all the 'files' in one form, the standard code is going to send them sequentially.  You would have to write the code to separate them and make separate connections if you wanted to send them all at the same time from one form.
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 1

Author Comment

by:aristanoble
ID: 39180168
@RainerJ if the front end code is written I can take care of the server side code. I've done it already one another front-end snippet I thought was chunking concurrently. I can just reapply it to this method; I just need the front-end part working.

@DaveBaldwin how would the separate connections work. Do you mean separate ajax calls to different URLs (e.g. $.ajax('upload.php'), $.ajax('upload2.php'), ...$.ajax('uploadn.php'))? Or separate ajax calls per chunk to the same URL?

Lastly, staying with the separate connection idea, could you guys update the js script so that it creates the separate connections based on the number of chunks involved? I'd imagine on the server a script would collect the chunks in an array indexed in the correct order until all pieces are collected, merge the code and then process; I can take care of that.
0
 
LVL 82

Accepted Solution

by:
Dave Baldwin earned 500 total points
ID: 39180345
You make separate AJAX connections to the same upload script.  I don't know what you mean by 'chunking', it's still a file upload from a form.  Note that while it is supposed to speed up uploading multiple files, you are still sharing the same limited bandwidth so it might not be a big a speed increase as you expect.
0
 
LVL 1

Author Comment

by:aristanoble
ID: 39180666
True but it's still an improvement over a single file upload, I can also defer the php process until later in order to speed things along even further.

Can you modify the current script where it slices the file into smaller chunks and write the code that will make the separate AJAX connections to the upload script?

I imagine it would be a loop for the number of chunks created and you'd send a numerical index along with each chunk that identifies it's position (i.e. index=1&chunk=firstPiece, index=2&secondPiece, index=5&fifthPiece, index=4&fourthPiece, index=3&thirdPiece) so that the server will know in which order to reassemble the pieces. Also, on the client, the callback functions handling the chunks should continue to fire as expected. That way I can use the "fileuploadchunkdone" callback for example in order to know when the last chunk was sent.
0
 
LVL 82

Expert Comment

by:Dave Baldwin
ID: 39181863
I don't have time to modify the code, too much work of my own to do.  

You keep talking about 'chunks'.  The actual file upload in AJAX or from a form is done by the browser according to the established internet standards.  And it is received on the server according to those same standards.  The process sends the whole file without any interaction by you or javascript.  Unless you are going to rewrite the browser and web server code, I don't think that is your choice.
0
 
LVL 1

Author Comment

by:aristanoble
ID: 39182794
The chunks I'm referring to is via the HTML5 File API. It allows for slicing the file into several smaller pieces (or chunks (of data)). Afterward, those several smaller files can be sent simultaneously to the server rather than one large single file.
0
 
LVL 1

Author Comment

by:aristanoble
ID: 39182870
If you can point out where I'd want to make those changes I'm sure I can figure it out myself. Based on the network traffic I've been looking through the code myself but I can't find the code that's posting the data to the server nor can I determine whats causing the few seconds of delay before the next slice is sent.
jquery.fileupload.js
0
 
LVL 1

Author Closing Comment

by:aristanoble
ID: 39183415
Thanks for your help guys; I fixed it. I was able to make separate ajax connections to the server.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now