Solved

How to concurrently upload file chunks rather than sequentially

Posted on 2013-05-19
13
1,656 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

This article discusses four methods for overlaying images in a container on a web page
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

627 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