fine-uploader
fine-uploader copied to clipboard
3 - Add feature to pause all uploads and block queued uploads from starting
I am using Angular JS in a single-page application with AngularJS inside of a UIWebView wrapper for an iOS app (with PhoneGap). When my app enters the background, there is no clean way for me to fully pause all upload functionality. It would be great if this was possible, so that my iOS app could pause uploads when the app enters the background and a have a corresponding 'resume' function that would pick everything back up from the state where it was paused so the uploads could be automatically started again when the app is resumed or when the user presses some sort of 'resume all' button.
I also have a need for this feature. Currently, I'm trying to do it the 'manual' way. I'm almost there, but it is tricky if autoUpload is true to begin with, changing that midstream when a 'pause' button is pressed.
If it's possible given the current v5.0.9 API, I would really appreciate a rough / pseudo-code method for pausing / unpausing that I could code up.
P.S. FineUploader is incredible in what it does..!
I imagine it would be tricky to pause all uploads when autoUpload
is enabled. You might need to simply monitor status via an onStatusChange
handler and attempt to pause any file with a status that isn't qq.status.PAUSED
. I haven't tested that though, just a thought. We'll keep this in mind for a future release.
Thanks Ray for the idea, I'll try it out. Yes, autoUpload pausing is tricky, as is autoUpload false then unpausing to initialize the queue. I've tried updating the sent options, but it doesn't seem to be 'responsive' to changes in the autoUpload except at variable initialization.
Either way, I'll try tying that in to onStatusChange to pause. Thanks for reviewing!
Ray, this is what I ended up doing with autoUpload
enabled. Without the setTimeout
, it is impossible to pause due to an error it can't pause (probably due to a synchronous call that happens shortly after the upload is triggered).
I don't love this solution because of the unpredictable nature of timeouts on various machines, but it is a solution.
.on("upload", function(event, id, name) {
if(! uploaderRunning) {
setTimeout(function() {
uploaderObj.fineUploader('pauseUpload', id);
}, 100);
}
})
I created the PR #1584 as we need this feature in our current project.
We are generating thumbnails by adding photos to the traditional FineUploader queue. The thumbnails are then uploaded by a S3 FineUploader, and the photos using the traditional one. Thing is, we need to upload the thumbnails in priority, and thus pause the traditional upload queue (because of the browser limitation) that will be unpaused once all the thumbnails are sent.
Please see my comments on your PR. There are a number of issues that will need to be resolved before this can be considered to be made a part of the library.