Solved

How to concurrently upload file chunks rather than sequentially

Posted on 2013-05-19
13
1,517 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
Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

 
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 83

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
 
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 83

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 83

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

The New “Normal” in Modern Enterprise Operations

DevOps for the modern enterprise offers many benefits — increased agility, productivity, and more, but digital transformation isn’t easy, especially if you’re not addressing the right issues. Register for the webinar to dive into the “new normal” for enterprise modern ops.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

821 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