Basic Version Auto-Resume Issue

457 views
Skip to first unread message

Aaron J Ban

unread,
Mar 31, 2013, 1:31:34 PM3/31/13
to jquery-f...@googlegroups.com
Hi, I'm using the basic version of the plugin and trying to implement automatic resumable uploads as per this tutorial:


It works great if I kill the browser window and then re-insert a file into the uploader manually.

But in the case of a lost network connection the fail event doesn't pick up the failed upload and resume it.

Is this possible using the basic version of the plugin? Here's the code I'm using:


$('#fileupload').fileupload({
dataType: 'json',
maxChunkSize: 100000,
add: function(e, data){

var that = this;
$.getJSON('server/php/', {file: data.files[0].name}, function (result) {

var file = result.file;
data.uploadedBytes = file && file.size;
$.blueimp.fileupload.prototype.options.add.call(that, e, data);


});

},
done: function(e, data){
$.each(data.result.files, function (index, file) {
console.log(file.name);
});
},
progress: function(e, data){
var progress = parseInt(data.loaded / data.total * 100, 10);
data.context.find($('.progress_bar_file')).css('width', progress + '%');
},
progressall: function(e, data){
var progress = parseInt(data.loaded / data.total * 100, 10);
$('#progress_total .progress_bar').css('width', progress + '%');
},
    maxRetries: 100,
   retryTimeout: 500,
   fail: function (e, data) {
       
       console.log('NETWORK FAILURE');
       
       // jQuery Widget Factory uses "namespace-widgetname" since version 1.10.0:
       var fu = $(this).data('blueimp-fileupload') || $(this).data('fileupload'),
           retries = data.context.data('retries') || 0,
           retry = function () {
               $.getJSON('server/php/', {file: data.files[0].name})
                   .done(function (result) {
                       var file = result.file;
                       data.uploadedBytes = file && file.size;
                       // clear the previous data:
                       data.data = null;
                       data.submit();
                   })
                   .fail(function () {
                       fu._trigger('fail', e, data);
                   });
           };
       if (data.errorThrown !== 'abort' &&
               data.uploadedBytes < data.files[0].size &&
               retries < fu.options.maxRetries) {
           retries += 1;
           data.context.data('retries', retries);
           window.setTimeout(retry, retries * fu.options.retryTimeout);
           return;
       }
       data.context.removeData('retries');
       $.blueimp.fileupload.prototype
           .options.fail.call(this, e, data);
   }
});

AJB

Gyula Fodor

unread,
Apr 27, 2014, 8:07:42 AM4/27/14
to jquery-f...@googlegroups.com
Hey Aaron,

Did you figure this out??

BR
Gyula

thedr...@gmx.at

unread,
Sep 1, 2014, 1:04:38 PM9/1/14
to jquery-f...@googlegroups.com
does it work now?
how did you fix it?
Reply all
Reply to author
Forward
0 new messages