Skip to content
This repository has been archived by the owner on May 25, 2023. It is now read-only.

Resume for chunked upload replaces file with remaining bytes #847

Closed
ghost opened this issue Dec 6, 2011 · 1 comment
Closed

Resume for chunked upload replaces file with remaining bytes #847

ghost opened this issue Dec 6, 2011 · 1 comment

Comments

@ghost
Copy link

ghost commented Dec 6, 2011

Hi,

Context:

I forked this project with the hope of creating a specialized version focused mainly on XHR2 chunked (blobsliced) uploads including cross-domain capability. I need to properly implement or configure resume (not restart) on network or server error.

Environment:

I setup the project on my MacbookPro (running Apache) and I'm accessing it by its LAN IP address (not localhost) so that I can manually disconnect the network (turn off wifi) on my machine to test resuming uploads upon network error. I'm also simulating a real connection's latency/bandwidth on my laptop (via SpeedLimit app) I'm using Firefox 8 in my tests.

Question:

All seems to be working fine except the "resume" portion, which I need (for very large files a 'restart' from scratch upon network/server error is not acceptable)

I've plugged in the replacement to 'fail' handler in application.js (not sure if 'fail' is actually triggered upon network interruption and actual server errors or if it's only triggered upon encountering {fail: true} from the Ajax call, i.e. I'm asking if 'fail' is only called on application error or also on network/server error) << can you clarify?

I also setup multi-part to false and chunk size to 20000 (very low since I only have small image files < 500Kb to test with right now so I need this low value to see detailed chunk by chunk progress visually)

What happens when I turn off wifi then turn it back on is that the uploading does indeed seem to resume (the progress bar resumes its progress from where it stopped) but when it's done what I see is always a file less than 20000 bytes, sometimes 14.7k and other times 19.2k etc.... I suppose this is the last remaining chunk that is overwriting the uploaded file in php/files.

I set the 'discard_aborted_uploads' in index.php to false but that only has an effect on the regular case of chunked uploads, not when I cause a network interruption.

Thanks for your help.

@blueimp
Copy link
Owner

blueimp commented Dec 6, 2011

The fail handler is the equivalent of the $.ajax error callback.
It's triggered for network errors (timeouts, HTTP error codes), upload abortion and parsing errors.
The UI version of the plugin also manually triggers it for canceling uploads that have not been started yet.

Thanks to your report I tested automatic resume and found a bug in the data.submit function, which prevented manually setting uploadedBytes during chunked uploads.
I will release an updated version (5.5.2) which fixes this issue.

I've also updated the guide for chunked file uploads and added an example on how to automatically retry and resume uploads:
https://github.com/blueimp/jQuery-File-Upload/wiki/Chunked-file-uploads

@blueimp blueimp closed this as completed in c99611a Dec 6, 2011
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant