diff --git a/dist/uploader.js b/dist/uploader.js index f9c1f85..36a6422 100644 --- a/dist/uploader.js +++ b/dist/uploader.js @@ -1,6 +1,6 @@ /*! * Uploader - Uploader library implements html5 file upload and provides multiple simultaneous, stable, fault tolerant and resumable uploads - * @version v0.3.2 + * @version v0.4.0 * @author dolymood * @link https://github.com/simple-uploader/Uploader * @license MIT @@ -69,6 +69,9 @@ utils.extend(Chunk.prototype, { }, getTarget: function (target, params) { + if (!params.length) { + return target + } if (target.indexOf('?') < 0) { target += '?' } else { @@ -280,6 +283,9 @@ utils.extend(Chunk.prototype, { var query = utils.evalOpts(this.uploader.opts.query, this.file, this, isTest) query = utils.extend(this.getParams(), query) + // processParams + query = this.uploader.opts.processParams(query) + var target = utils.evalOpts(this.uploader.opts.target, this.file, this, isTest) var data = null if (method === 'GET' || paramsMethod === 'octet') { @@ -371,7 +377,7 @@ var event = _dereq_('./event') var File = _dereq_('./file') var Chunk = _dereq_('./chunk') -var version = '0.3.2' +var version = '0.4.0' var isServer = typeof window === 'undefined' @@ -469,6 +475,9 @@ Uploader.defaults = { initialPaused: false, processResponse: function (response, cb) { cb(null, response) + }, + processParams: function (params) { + return params } } diff --git a/dist/uploader.min.js b/dist/uploader.min.js index 2750a64..81b300d 100644 --- a/dist/uploader.min.js +++ b/dist/uploader.min.js @@ -1,9 +1,9 @@ /*! * Uploader - Uploader library implements html5 file upload and provides multiple simultaneous, stable, fault tolerant and resumable uploads - * @version v0.3.2 + * @version v0.4.0 * @author dolymood * @link https://github.com/simple-uploader/Uploader * @license MIT */ -!function(e){if("object"==typeof exports)module.exports=e();else if("function"==typeof define&&define.amd)define(e);else{var t;"undefined"!=typeof window?t=window:"undefined"!=typeof global?t=global:"undefined"!=typeof self&&(t=self),t.Uploader=e()}}(function(){return function r(n,a,o){function h(i,e){if(!a[i]){if(!n[i]){var t="function"==typeof require&&require;if(!e&&t)return t(i,!0);if(u)return u(i,!0);throw new Error("Cannot find module '"+i+"'")}var s=a[i]={exports:{}};n[i][0].call(s.exports,function(e){var t=n[i][1][e];return h(t||e)},s,s.exports,r,n,a,o)}return a[i].exports}for(var u="function"==typeof require&&require,e=0;e=this.uploader.opts.maxChunkRetries?t=a.ERROR:(this.abort(),t=a.PENDING);var i=this.processedState;return i&&i.err&&(t=a.ERROR),t}return a.PENDING},message:function(){return this.xhr?this.xhr.responseText:""},progress:function(){if(this.pendingRetry)return 0;var e=this.status();return e===a.SUCCESS||e===a.ERROR?1:e===a.PENDING?0:0=this.uploader.opts.progressCallbacksInterval},_chunkEvent:function(t,e,i){var s=this.uploader,r=u.STATUS,n=this,a=this.getRoot(),o=function(e){n._measureSpeed(e),s._trigger("fileProgress",a,n,t),n._lastProgressCallback=Date.now()};switch(e){case r.PROGRESS:this._checkProgress()&&o();break;case r.ERROR:this._error(),this.abort(!0),s._trigger("fileError",a,this,i,t);break;case r.SUCCESS:if(this._updateUploadedChunks(i,t),this.error)return;clearTimeout(this._progeressId),this._progeressId=0;var h=Date.now()-this._lastProgressCallback;h>>0)).toLowerCase()}}),t.exports=a},{"./chunk":1,"./utils":5}],5:[function(e,t,i){var s=Object.prototype,r=Array.prototype,n=s.toString,l=function(e){return"[object Function]"===n.call(e)},p=Array.isArray||function(e){return"[object Array]"===n.call(e)},c=function(e){return"[object Object]"===n.call(e)&&Object.getPrototypeOf(e)===s},a=0,f={uid:function(){return++a},noop:function(){},bind:function(e,t){return function(){return e.apply(t,arguments)}},preventEvent:function(e){e.preventDefault()},stop:function(e){e.preventDefault(),e.stopPropagation()},nextTick:function(e,t){setTimeout(f.bind(e,t),0)},toArray:function(e,t,i){return void 0===t&&(t=0),void 0===i&&(i=e.length),r.slice.call(e,t,i)},isPlainObject:c,isFunction:l,isArray:p,isObject:function(e){return Object(e)===e},isString:function(e){return"string"==typeof e},isUndefined:function(e){return void 0===e},isDefined:function(e){return void 0!==e},each:function(e,t,i){if(f.isDefined(e.length))for(var s=0,r=e.length;s=this.uploader.opts.maxChunkRetries?t=a.ERROR:(this.abort(),t=a.PENDING);var i=this.processedState;return i&&i.err&&(t=a.ERROR),t}return a.PENDING},message:function(){return this.xhr?this.xhr.responseText:""},progress:function(){if(this.pendingRetry)return 0;var e=this.status();return e===a.SUCCESS||e===a.ERROR?1:e===a.PENDING?0:0=this.uploader.opts.progressCallbacksInterval},_chunkEvent:function(t,e,i){var s=this.uploader,r=u.STATUS,n=this,a=this.getRoot(),o=function(e){n._measureSpeed(e),s._trigger("fileProgress",a,n,t),n._lastProgressCallback=Date.now()};switch(e){case r.PROGRESS:this._checkProgress()&&o();break;case r.ERROR:this._error(),this.abort(!0),s._trigger("fileError",a,this,i,t);break;case r.SUCCESS:if(this._updateUploadedChunks(i,t),this.error)return;clearTimeout(this._progeressId),this._progeressId=0;var h=Date.now()-this._lastProgressCallback;h>>0)).toLowerCase()}}),t.exports=a},{"./chunk":1,"./utils":5}],5:[function(e,t,i){var s=Object.prototype,r=Array.prototype,n=s.toString,l=function(e){return"[object Function]"===n.call(e)},p=Array.isArray||function(e){return"[object Array]"===n.call(e)},c=function(e){return"[object Object]"===n.call(e)&&Object.getPrototypeOf(e)===s},a=0,f={uid:function(){return++a},noop:function(){},bind:function(e,t){return function(){return e.apply(t,arguments)}},preventEvent:function(e){e.preventDefault()},stop:function(e){e.preventDefault(),e.stopPropagation()},nextTick:function(e,t){setTimeout(f.bind(e,t),0)},toArray:function(e,t,i){return void 0===t&&(t=0),void 0===i&&(i=e.length),r.slice.call(e,t,i)},isPlainObject:c,isFunction:l,isArray:p,isObject:function(e){return Object(e)===e},isString:function(e){return"string"==typeof e},isUndefined:function(e){return void 0===e},isDefined:function(e){return void 0!==e},each:function(e,t,i){if(f.isDefined(e.length))for(var s=0,r=e.length;s