From 9b8e54a81c42fabdda34c4d9fe72e5ba6142f5de Mon Sep 17 00:00:00 2001 From: Dmitry Khromov Date: Mon, 19 Jan 2015 08:01:26 +0300 Subject: [PATCH 1/2] we ignoring data from first occurrence --- .../javascripts/jquery-fileupload/jquery.fileupload.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/jquery-fileupload/jquery.fileupload.js b/app/assets/javascripts/jquery-fileupload/jquery.fileupload.js index a4cfdc0..272817b 100644 --- a/app/assets/javascripts/jquery-fileupload/jquery.fileupload.js +++ b/app/assets/javascripts/jquery-fileupload/jquery.fileupload.js @@ -412,13 +412,19 @@ xhr = options.xhr ? options.xhr() : $.ajaxSettings.xhr(); // Accesss to the native XHR object is required to add event listeners // for the upload progress event: + var first_occurrence = true if (xhr.upload) { $(xhr.upload).bind('progress', function (e) { var oe = e.originalEvent; // Make sure the progress event properties get copied over: e.lengthComputable = oe.lengthComputable; - e.loaded = oe.loaded; - e.total = oe.total; + if(first_occurrence == true) { + oe.loaded = 0; + e.loaded = 0; + } else { + e.loaded = oe.loaded; + first_occurrence = false; + } that._onProgress(e, options); }); options.xhr = function () { From dfd1293e55fe0f69305919235947c2ff83024bbc Mon Sep 17 00:00:00 2001 From: Dmitry Khromov Date: Mon, 19 Jan 2015 09:20:25 +0300 Subject: [PATCH 2/2] fix --- app/assets/javascripts/jquery-fileupload/jquery.fileupload.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/jquery-fileupload/jquery.fileupload.js b/app/assets/javascripts/jquery-fileupload/jquery.fileupload.js index 272817b..f1caab2 100644 --- a/app/assets/javascripts/jquery-fileupload/jquery.fileupload.js +++ b/app/assets/javascripts/jquery-fileupload/jquery.fileupload.js @@ -421,10 +421,11 @@ if(first_occurrence == true) { oe.loaded = 0; e.loaded = 0; + first_occurrence = false; } else { e.loaded = oe.loaded; - first_occurrence = false; } + e.total = oe.total; that._onProgress(e, options); }); options.xhr = function () {