diff options
author | zotlabs <mike@macgirvin.com> | 2019-09-26 18:36:06 -0700 |
---|---|---|
committer | zotlabs <mike@macgirvin.com> | 2019-09-26 18:36:06 -0700 |
commit | 02f5fa32af4708877c89a50d5fa8849f6d9e038e (patch) | |
tree | d3067651098c636e6093ada64f3b65881ade1eed /vendor/blueimp/jquery-file-upload/js/jquery.fileupload.js | |
parent | b6590e95b5429ec50eccd3bb9c70ff0127dbd1cb (diff) | |
parent | ec65211d54d07787871befe0e4658a469a735301 (diff) | |
download | volse-hubzilla-02f5fa32af4708877c89a50d5fa8849f6d9e038e.tar.gz volse-hubzilla-02f5fa32af4708877c89a50d5fa8849f6d9e038e.tar.bz2 volse-hubzilla-02f5fa32af4708877c89a50d5fa8849f6d9e038e.zip |
Merge branch 'dev' of https://framagit.org/hubzilla/core into dev
Diffstat (limited to 'vendor/blueimp/jquery-file-upload/js/jquery.fileupload.js')
-rw-r--r-- | vendor/blueimp/jquery-file-upload/js/jquery.fileupload.js | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/vendor/blueimp/jquery-file-upload/js/jquery.fileupload.js b/vendor/blueimp/jquery-file-upload/js/jquery.fileupload.js index 700f9013c..53c169e2a 100644 --- a/vendor/blueimp/jquery-file-upload/js/jquery.fileupload.js +++ b/vendor/blueimp/jquery-file-upload/js/jquery.fileupload.js @@ -165,6 +165,15 @@ bitrateInterval: 500, // By default, uploads are started automatically when adding files: autoUpload: true, + // By default, duplicate file names are expected to be handled on + // the server-side. If this is not possible (e.g. when uploading + // files directly to Amazon S3), the following option can be set to + // an empty object or an object mapping existing filenames, e.g.: + // { "image.jpg": true, "image (1).jpg": true } + // If it is set, all files will be uploaded with unique filenames, + // adding increasing number suffixes if necessary, e.g.: + // "image (2).jpg" + uniqueFilenames: undefined, // Error and info messages: messages: { @@ -449,6 +458,23 @@ return Object.prototype.toString.call(obj) === '[object ' + type + ']'; }, + _getUniqueFilename: function (name, map) { + name = String(name); + if (map[name]) { + name = name.replace( + /(?: \(([\d]+)\))?(\.[^.]+)?$/, + function (_, p1, p2) { + var index = p1 ? Number(p1) + 1 : 1; + var ext = p2 || ''; + return ' (' + index + ')' + ext; + } + ); + return this._getUniqueFilename(name, map); + } + map[name] = true; + return name; + }, + _initXHRData: function (options) { var that = this, formData, @@ -510,11 +536,18 @@ // dummy objects: if (that._isInstanceOf('File', file) || that._isInstanceOf('Blob', file)) { + var fileName = file.uploadName || file.name; + if (options.uniqueFilenames) { + fileName = that._getUniqueFilename( + fileName, + options.uniqueFilenames + ); + } formData.append( ($.type(options.paramName) === 'array' && options.paramName[index]) || paramName, file, - file.uploadName || file.name + fileName ); } }); |