aboutsummaryrefslogtreecommitdiffstats
path: root/library/blueimp_upload/js/jquery.fileupload.js
diff options
context:
space:
mode:
Diffstat (limited to 'library/blueimp_upload/js/jquery.fileupload.js')
-rw-r--r--library/blueimp_upload/js/jquery.fileupload.js32
1 files changed, 26 insertions, 6 deletions
diff --git a/library/blueimp_upload/js/jquery.fileupload.js b/library/blueimp_upload/js/jquery.fileupload.js
index 5ff151b53..700f9013c 100644
--- a/library/blueimp_upload/js/jquery.fileupload.js
+++ b/library/blueimp_upload/js/jquery.fileupload.js
@@ -43,7 +43,7 @@
'|(Kindle/(1\\.0|2\\.[05]|3\\.0))'
).test(window.navigator.userAgent) ||
// Feature detection for all other devices:
- $('<input type="file">').prop('disabled'));
+ $('<input type="file"/>').prop('disabled'));
// The FileReader API is not actually used, but works as feature detection,
// as some Safari versions (5?) support XHR file uploads via the FormData API,
@@ -261,6 +261,9 @@
// Callback for dragover events of the dropZone(s):
// dragover: function (e) {}, // .bind('fileuploaddragover', func);
+ // Callback before the start of each chunk upload request (before form data initialization):
+ // chunkbeforesend: function (e, data) {}, // .bind('fileuploadchunkbeforesend', func);
+
// Callback for the start of each chunk upload request:
// chunksend: function (e, data) {}, // .bind('fileuploadchunksend', func);
@@ -434,6 +437,13 @@
}
},
+ _deinitProgressListener: function (options) {
+ var xhr = options.xhr ? options.xhr() : $.ajaxSettings.xhr();
+ if (xhr.upload) {
+ $(xhr.upload).unbind('progress');
+ }
+ },
+
_isInstanceOf: function (type, obj) {
// Cross-frame instanceof check
return Object.prototype.toString.call(obj) === '[object ' + type + ']';
@@ -453,7 +463,7 @@
}
if (!multipart || options.blob || !this._isInstanceOf('File', file)) {
options.headers['Content-Disposition'] = 'attachment; filename="' +
- encodeURI(file.name) + '"';
+ encodeURI(file.uploadName || file.name) + '"';
}
if (!multipart) {
options.contentType = file.type || 'application/octet-stream';
@@ -489,7 +499,11 @@
});
}
if (options.blob) {
- formData.append(paramName, options.blob, file.name);
+ formData.append(
+ paramName,
+ options.blob,
+ file.uploadName || file.name
+ );
} else {
$.each(options.files, function (index, file) {
// This check allows the tests to run with
@@ -730,7 +744,7 @@
promise = dfd.promise(),
jqXHR,
upload;
- if (!(this._isXHRUpload(options) && slice && (ub || mcs < fs)) ||
+ if (!(this._isXHRUpload(options) && slice && (ub || ($.type(mcs) === 'function' ? mcs(options) : mcs) < fs)) ||
options.data) {
return false;
}
@@ -753,7 +767,7 @@
o.blob = slice.call(
file,
ub,
- ub + mcs,
+ ub + ($.type(mcs) === 'function' ? mcs(o) : mcs),
file.type
);
// Store the current chunk size, as the blob itself
@@ -762,6 +776,8 @@
// Expose the chunk bytes position range:
o.contentRange = 'bytes ' + ub + '-' +
(ub + o.chunkSize - 1) + '/' + fs;
+ // Trigger chunkbeforesend to allow form data to be updated for this chunk
+ that._trigger('chunkbeforesend', null, o);
// Process the upload data (the blob and potential form data):
that._initXHRData(o);
// Add progress listeners for this chunk upload:
@@ -808,6 +824,9 @@
o.context,
[jqXHR, textStatus, errorThrown]
);
+ })
+ .always(function () {
+ that._deinitProgressListener(o);
});
};
this._enhancePromise(promise);
@@ -909,6 +928,7 @@
}).fail(function (jqXHR, textStatus, errorThrown) {
that._onFail(jqXHR, textStatus, errorThrown, options);
}).always(function (jqXHRorResult, textStatus, jqXHRorError) {
+ that._deinitProgressListener(options);
that._onAlways(
jqXHRorResult,
textStatus,
@@ -1126,7 +1146,7 @@
dirReader = entry.createReader();
readEntries();
} else {
- // Return an empy list for file system items
+ // Return an empty list for file system items
// other than files or directories:
dfd.resolve([]);
}