Solved

How to concurrently upload file chunks rather than sequentially

Posted on 2013-05-19
13
1,573 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
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Introduction Chart.js, used properly, can visually add a difference to your charting applications. It engages your visitors and allows them to interact with data they otherwise wouldn't be able to without expensive and complicated systems. For this…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

752 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