• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1901
  • Last Modified:

How to concurrently upload file chunks rather than sequentially

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
aristanoble
Asked:
aristanoble
  • 7
  • 3
  • 3
2 Solutions
 
Rainer JeschorCommented:
Hi,
which upload plugin are you using?
Attachment is missing.
Thanks.
Rainer
0
 
aristanobleAuthor Commented:
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
 
Rainer JeschorCommented:
Hi,
from the project owner:
https://github.com/blueimp/jQuery-File-Upload/issues/2188
this is not implemented / supported.
Sorry, HTH
Rainer
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

 
aristanobleAuthor Commented:
I know. Any reason why it can't be done; I know without a doubt in my mind that it can.
0
 
Rainer JeschorCommented:
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
 
Dave BaldwinFixer of ProblemsCommented:
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
 
aristanobleAuthor Commented:
@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
 
Dave BaldwinFixer of ProblemsCommented:
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
 
aristanobleAuthor Commented:
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
 
Dave BaldwinFixer of ProblemsCommented:
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
 
aristanobleAuthor Commented:
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
 
aristanobleAuthor Commented:
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
 
aristanobleAuthor Commented:
Thanks for your help guys; I fixed it. I was able to make separate ajax connections to the server.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

  • 7
  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now