ng2-file-upload
Advanced tools
Comparing version 1.2.1 to 1.3.0
@@ -10,3 +10,3 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
root["ng2-file-upload.umd"] = factory(root["@angular/core"], root["@angular/common"]); | ||
})(this, function(__WEBPACK_EXTERNAL_MODULE_2__, __WEBPACK_EXTERNAL_MODULE_8__) { | ||
})(this, function(__WEBPACK_EXTERNAL_MODULE_0__, __WEBPACK_EXTERNAL_MODULE_8__) { | ||
return /******/ (function(modules) { // webpackBootstrap | ||
@@ -82,2 +82,8 @@ /******/ // The module cache | ||
/* 0 */ | ||
/***/ (function(module, exports) { | ||
module.exports = __WEBPACK_EXTERNAL_MODULE_0__; | ||
/***/ }), | ||
/* 1 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -92,2 +98,3 @@ | ||
function FileLikeObject(fileOrInput) { | ||
this.rawFile = fileOrInput; | ||
var isInput = isElement(fileOrInput); | ||
@@ -106,3 +113,2 @@ var fakePathOrObject = isInput ? fileOrInput.value : fileOrInput; | ||
FileLikeObject.prototype._createFromObject = function (object) { | ||
// this.lastModifiedDate = copy(object.lastModifiedDate); | ||
this.size = object.size; | ||
@@ -118,3 +124,3 @@ this.type = object.type; | ||
/***/ }), | ||
/* 1 */ | ||
/* 2 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -124,3 +130,4 @@ | ||
var file_like_object_class_1 = __webpack_require__(0); | ||
var core_1 = __webpack_require__(0); | ||
var file_like_object_class_1 = __webpack_require__(1); | ||
var file_item_class_1 = __webpack_require__(4); | ||
@@ -142,11 +149,14 @@ var file_type_class_1 = __webpack_require__(7); | ||
removeAfterUpload: false, | ||
disableMultipart: false | ||
disableMultipart: false, | ||
formatDataFunction: function (item) { return item._file; }, | ||
formatDataFunctionIsAsync: false | ||
}; | ||
this.setOptions(options); | ||
this.response = new core_1.EventEmitter(); | ||
} | ||
FileUploader.prototype.setOptions = function (options) { | ||
this.options = Object.assign(this.options, options); | ||
this.authToken = options.authToken; | ||
this.authTokenHeader = options.authTokenHeader || 'Authorization'; | ||
this.autoUpload = options.autoUpload; | ||
this.authToken = this.options.authToken; | ||
this.authTokenHeader = this.options.authTokenHeader || 'Authorization'; | ||
this.autoUpload = this.options.autoUpload; | ||
this.options.filters.unshift({ name: 'queueLimit', fn: this._queueLimitFilter }); | ||
@@ -165,3 +175,2 @@ if (this.options.maxFileSize) { | ||
} | ||
// this.options.filters.unshift({name: 'folder', fn: this._folderFilter}); | ||
}; | ||
@@ -268,7 +277,2 @@ FileUploader.prototype.addToQueue = function (files, options, filters) { | ||
return void 0; | ||
/*forEach(this._directives, (key) => { | ||
forEach(this._directives[key], (object) => { | ||
object.destroy(); | ||
}); | ||
});*/ | ||
}; | ||
@@ -348,11 +352,6 @@ FileUploader.prototype.onAfterAddingAll = function (fileItems) { | ||
var _this = this; | ||
var that = this; | ||
var xhr = item._xhr = new XMLHttpRequest(); | ||
var sendable; | ||
this._onBeforeUploadItem(item); | ||
// todo | ||
/*item.formData.map(obj => { | ||
obj.map((value, key) => { | ||
form.append(key, value); | ||
}); | ||
});*/ | ||
if (typeof item._file.size !== 'number') { | ||
@@ -364,11 +363,23 @@ throw new TypeError('The file specified is no longer valid'); | ||
this._onBuildItemForm(item, sendable); | ||
sendable.append(item.alias, item._file, item.file.name); | ||
var appendFile = function () { return sendable.append(item.alias, item._file, item.file.name); }; | ||
if (!this.options.parametersBeforeFiles) { | ||
appendFile(); | ||
} | ||
// For AWS, Additional Parameters must come BEFORE Files | ||
if (this.options.additionalParameter !== undefined) { | ||
Object.keys(this.options.additionalParameter).forEach(function (key) { | ||
sendable.append(key, _this.options.additionalParameter[key]); | ||
var paramVal = _this.options.additionalParameter[key]; | ||
// Allow an additional parameter to include the filename | ||
if (typeof paramVal === 'string' && paramVal.indexOf('{{file_name}}') >= 0) { | ||
paramVal = paramVal.replace('{{file_name}}', item.file.name); | ||
} | ||
sendable.append(key, paramVal); | ||
}); | ||
} | ||
if (this.options.parametersBeforeFiles) { | ||
appendFile(); | ||
} | ||
} | ||
else { | ||
sendable = item._file; | ||
sendable = this.options.formatDataFunction(item); | ||
} | ||
@@ -416,3 +427,13 @@ xhr.upload.onprogress = function (event) { | ||
} | ||
xhr.send(sendable); | ||
xhr.onreadystatechange = function () { | ||
if (xhr.readyState == XMLHttpRequest.DONE) { | ||
that.response.emit(xhr.responseText); | ||
} | ||
}; | ||
if (this.options.formatDataFunctionIsAsync) { | ||
sendable.then(function (result) { return xhr.send(JSON.stringify(result)); }); | ||
} | ||
else { | ||
xhr.send(sendable); | ||
} | ||
this._render(); | ||
@@ -447,7 +468,3 @@ }; | ||
return void 0; | ||
// todo: ? | ||
}; | ||
// protected _folderFilter(item:FileItem):boolean { | ||
// return !!(item.size || item.type); | ||
// } | ||
FileUploader.prototype._queueLimitFilter = function () { | ||
@@ -467,12 +484,5 @@ return this.options.queueLimit === undefined || this.queue.length < this.options.queueLimit; | ||
}; | ||
/* tslint:disable */ | ||
FileUploader.prototype._transformResponse = function (response, headers) { | ||
// todo: ? | ||
/*var headersGetter = this._headersGetter(headers); | ||
forEach($http.defaults.transformResponse, (transformFn) => { | ||
response = transformFn(response, headersGetter); | ||
});*/ | ||
return response; | ||
}; | ||
/* tslint:enable */ | ||
FileUploader.prototype._parseHeaders = function (headers) { | ||
@@ -496,5 +506,2 @@ var parsed = {}; | ||
}; | ||
/*protected _iframeTransport(item:FileItem) { | ||
// todo: implement it later | ||
}*/ | ||
FileUploader.prototype._onWhenAddingFileFailed = function (item, filter, options) { | ||
@@ -525,3 +532,2 @@ this.onWhenAddingFileFailed(item, filter, options); | ||
}; | ||
/* tslint:disable */ | ||
FileUploader.prototype._onSuccessItem = function (item, response, status, headers) { | ||
@@ -531,3 +537,2 @@ item._onSuccess(response, status, headers); | ||
}; | ||
/* tslint:enable */ | ||
FileUploader.prototype._onCancelItem = function (item, response, status, headers) { | ||
@@ -543,8 +548,2 @@ item._onCancel(response, status, headers); | ||
/***/ }), | ||
/* 2 */ | ||
/***/ (function(module, exports) { | ||
module.exports = __WEBPACK_EXTERNAL_MODULE_2__; | ||
/***/ }), | ||
/* 3 */ | ||
@@ -564,4 +563,4 @@ /***/ (function(module, exports, __webpack_require__) { | ||
}; | ||
var core_1 = __webpack_require__(2); | ||
var file_uploader_class_1 = __webpack_require__(1); | ||
var core_1 = __webpack_require__(0); | ||
var file_uploader_class_1 = __webpack_require__(2); | ||
var FileDropDirective = (function () { | ||
@@ -675,3 +674,3 @@ function FileDropDirective(element) { | ||
var file_like_object_class_1 = __webpack_require__(0); | ||
var file_like_object_class_1 = __webpack_require__(1); | ||
var FileItem = (function () { | ||
@@ -818,7 +817,7 @@ function FileItem(uploader, some, options) { | ||
}; | ||
var core_1 = __webpack_require__(2); | ||
var file_uploader_class_1 = __webpack_require__(1); | ||
// todo: filters | ||
var core_1 = __webpack_require__(0); | ||
var file_uploader_class_1 = __webpack_require__(2); | ||
var FileSelectDirective = (function () { | ||
function FileSelectDirective(element) { | ||
this.onFileSelected = new core_1.EventEmitter(); | ||
this.element = element; | ||
@@ -830,3 +829,3 @@ } | ||
FileSelectDirective.prototype.getFilters = function () { | ||
return void 0; | ||
return {}; | ||
}; | ||
@@ -837,10 +836,8 @@ FileSelectDirective.prototype.isEmptyAfterSelection = function () { | ||
FileSelectDirective.prototype.onChange = function () { | ||
// let files = this.uploader.isHTML5 ? this.element.nativeElement[0].files : this.element.nativeElement[0]; | ||
var files = this.element.nativeElement.files; | ||
var options = this.getOptions(); | ||
var filters = this.getFilters(); | ||
// if(!this.uploader.isHTML5) this.destroy(); | ||
this.uploader.addToQueue(files, options, filters); | ||
this.onFileSelected.emit(files); | ||
if (this.isEmptyAfterSelection()) { | ||
// todo | ||
this.element.nativeElement.value = ''; | ||
@@ -856,2 +853,6 @@ } | ||
__decorate([ | ||
core_1.Output(), | ||
__metadata("design:type", core_1.EventEmitter) | ||
], FileSelectDirective.prototype, "onFileSelected", void 0); | ||
__decorate([ | ||
core_1.HostListener('change'), | ||
@@ -882,3 +883,3 @@ __metadata("design:type", Function), | ||
var common_1 = __webpack_require__(8); | ||
var core_1 = __webpack_require__(2); | ||
var core_1 = __webpack_require__(0); | ||
var file_drop_directive_1 = __webpack_require__(3); | ||
@@ -970,2 +971,3 @@ var file_select_directive_1 = __webpack_require__(5); | ||
'compress': 'compress', | ||
'zip': 'compress', | ||
'rar': 'compress', | ||
@@ -1088,5 +1090,5 @@ '7z': 'compress', | ||
__export(__webpack_require__(3)); | ||
__export(__webpack_require__(2)); | ||
__export(__webpack_require__(4)); | ||
__export(__webpack_require__(1)); | ||
__export(__webpack_require__(4)); | ||
__export(__webpack_require__(0)); | ||
var file_upload_module_1 = __webpack_require__(6); | ||
@@ -1093,0 +1095,0 @@ exports.FileUploadModule = file_upload_module_1.FileUploadModule; |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@angular/core"),require("@angular/common")):"function"==typeof define&&define.amd?define(["@angular/core","@angular/common"],t):"object"==typeof exports?exports["ng2-file-upload.umd.min"]=t(require("@angular/core"),require("@angular/common")):e["ng2-file-upload.umd.min"]=t(e["@angular/core"],e["@angular/common"])}(this,function(e,t){return function(e){function t(i){if(o[i])return o[i].exports;var n=o[i]={i:i,l:!1,exports:{}};return e[i].call(n.exports,n,n.exports,t),n.l=!0,n.exports}var o={};return t.m=e,t.c=o,t.i=function(e){return e},t.d=function(e,o,i){t.o(e,o)||Object.defineProperty(e,o,{configurable:!1,enumerable:!0,get:i})},t.n=function(e){var o=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(o,"a",o),o},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="/",t(t.s=9)}([function(e,t,o){"use strict";function i(e){return!(!e||!(e.nodeName||e.prop&&e.attr&&e.find))}var n=function(){function e(e){var t=i(e),o=t?e.value:e;this["_createFrom"+("string"==typeof o?"FakePath":"Object")](o)}return e.prototype._createFromFakePath=function(e){this.lastModifiedDate=void 0,this.size=void 0,this.type="like/"+e.slice(e.lastIndexOf(".")+1).toLowerCase(),this.name=e.slice(e.lastIndexOf("/")+e.lastIndexOf("\\")+2)},e.prototype._createFromObject=function(e){this.size=e.size,this.type=e.type,this.name=e.name},e}();t.FileLikeObject=n},function(e,t,o){"use strict";function i(e){return File&&e instanceof File}var n=o(0),r=o(4),s=o(7),p=function(){function e(e){this.isUploading=!1,this.queue=[],this.progress=0,this._nextIndex=0,this.options={autoUpload:!1,isHTML5:!0,filters:[],removeAfterUpload:!1,disableMultipart:!1},this.setOptions(e)}return e.prototype.setOptions=function(e){this.options=Object.assign(this.options,e),this.authToken=e.authToken,this.authTokenHeader=e.authTokenHeader||"Authorization",this.autoUpload=e.autoUpload,this.options.filters.unshift({name:"queueLimit",fn:this._queueLimitFilter}),this.options.maxFileSize&&this.options.filters.unshift({name:"fileSize",fn:this._fileSizeFilter}),this.options.allowedFileType&&this.options.filters.unshift({name:"fileType",fn:this._fileTypeFilter}),this.options.allowedMimeType&&this.options.filters.unshift({name:"mimeType",fn:this._mimeTypeFilter});for(var t=0;t<this.queue.length;t++)this.queue[t].url=this.options.url},e.prototype.addToQueue=function(e,t,o){for(var i=this,s=[],p=0,a=e;p<a.length;p++){var l=a[p];s.push(l)}var u=this._getFilters(o),c=this.queue.length,d=[];s.map(function(e){t||(t=i.options);var o=new n.FileLikeObject(e);if(i._isValidFile(o,u,t)){var s=new r.FileItem(i,e,t);d.push(s),i.queue.push(s),i._onAfterAddingFile(s)}else{var p=u[i._failFilterIndex];i._onWhenAddingFileFailed(o,p,t)}}),this.queue.length!==c&&(this._onAfterAddingAll(d),this.progress=this._getTotalProgress()),this._render(),this.options.autoUpload&&this.uploadAll()},e.prototype.removeFromQueue=function(e){var t=this.getIndexOfItem(e),o=this.queue[t];o.isUploading&&o.cancel(),this.queue.splice(t,1),this.progress=this._getTotalProgress()},e.prototype.clearQueue=function(){for(;this.queue.length;)this.queue[0].remove();this.progress=0},e.prototype.uploadItem=function(e){var t=this.getIndexOfItem(e),o=this.queue[t],i=this.options.isHTML5?"_xhrTransport":"_iframeTransport";o._prepareToUploading(),this.isUploading||(this.isUploading=!0,this[i](o))},e.prototype.cancelItem=function(e){var t=this.getIndexOfItem(e),o=this.queue[t],i=this.options.isHTML5?o._xhr:o._form;o&&o.isUploading&&i.abort()},e.prototype.uploadAll=function(){var e=this.getNotUploadedItems().filter(function(e){return!e.isUploading});e.length&&(e.map(function(e){return e._prepareToUploading()}),e[0].upload())},e.prototype.cancelAll=function(){this.getNotUploadedItems().map(function(e){return e.cancel()})},e.prototype.isFile=function(e){return i(e)},e.prototype.isFileLikeObject=function(e){return e instanceof n.FileLikeObject},e.prototype.getIndexOfItem=function(e){return"number"==typeof e?e:this.queue.indexOf(e)},e.prototype.getNotUploadedItems=function(){return this.queue.filter(function(e){return!e.isUploaded})},e.prototype.getReadyItems=function(){return this.queue.filter(function(e){return e.isReady&&!e.isUploading}).sort(function(e,t){return e.index-t.index})},e.prototype.destroy=function(){},e.prototype.onAfterAddingAll=function(e){return{fileItems:e}},e.prototype.onBuildItemForm=function(e,t){return{fileItem:e,form:t}},e.prototype.onAfterAddingFile=function(e){return{fileItem:e}},e.prototype.onWhenAddingFileFailed=function(e,t,o){return{item:e,filter:t,options:o}},e.prototype.onBeforeUploadItem=function(e){return{fileItem:e}},e.prototype.onProgressItem=function(e,t){return{fileItem:e,progress:t}},e.prototype.onProgressAll=function(e){return{progress:e}},e.prototype.onSuccessItem=function(e,t,o,i){return{item:e,response:t,status:o,headers:i}},e.prototype.onErrorItem=function(e,t,o,i){return{item:e,response:t,status:o,headers:i}},e.prototype.onCancelItem=function(e,t,o,i){return{item:e,response:t,status:o,headers:i}},e.prototype.onCompleteItem=function(e,t,o,i){return{item:e,response:t,status:o,headers:i}},e.prototype.onCompleteAll=function(){},e.prototype._mimeTypeFilter=function(e){return!(this.options.allowedMimeType&&-1===this.options.allowedMimeType.indexOf(e.type))},e.prototype._fileSizeFilter=function(e){return!(this.options.maxFileSize&&e.size>this.options.maxFileSize)},e.prototype._fileTypeFilter=function(e){return!(this.options.allowedFileType&&-1===this.options.allowedFileType.indexOf(s.FileType.getMimeClass(e)))},e.prototype._onErrorItem=function(e,t,o,i){e._onError(t,o,i),this.onErrorItem(e,t,o,i)},e.prototype._onCompleteItem=function(e,t,o,i){e._onComplete(t,o,i),this.onCompleteItem(e,t,o,i);var n=this.getReadyItems()[0];if(this.isUploading=!1,n)return void n.upload();this.onCompleteAll(),this.progress=this._getTotalProgress(),this._render()},e.prototype._headersGetter=function(e){return function(t){return t?e[t.toLowerCase()]||void 0:e}},e.prototype._xhrTransport=function(e){var t,o=this,i=e._xhr=new XMLHttpRequest;if(this._onBeforeUploadItem(e),"number"!=typeof e._file.size)throw new TypeError("The file specified is no longer valid");if(this.options.disableMultipart?t=e._file:(t=new FormData,this._onBuildItemForm(e,t),t.append(e.alias,e._file,e.file.name),void 0!==this.options.additionalParameter&&Object.keys(this.options.additionalParameter).forEach(function(e){t.append(e,o.options.additionalParameter[e])})),i.upload.onprogress=function(t){var i=Math.round(t.lengthComputable?100*t.loaded/t.total:0);o._onProgressItem(e,i)},i.onload=function(){var t=o._parseHeaders(i.getAllResponseHeaders()),n=o._transformResponse(i.response,t),r=o._isSuccessCode(i.status)?"Success":"Error";o["_on"+r+"Item"](e,n,i.status,t),o._onCompleteItem(e,n,i.status,t)},i.onerror=function(){var t=o._parseHeaders(i.getAllResponseHeaders()),n=o._transformResponse(i.response,t);o._onErrorItem(e,n,i.status,t),o._onCompleteItem(e,n,i.status,t)},i.onabort=function(){var t=o._parseHeaders(i.getAllResponseHeaders()),n=o._transformResponse(i.response,t);o._onCancelItem(e,n,i.status,t),o._onCompleteItem(e,n,i.status,t)},i.open(e.method,e.url,!0),i.withCredentials=e.withCredentials,this.options.headers)for(var n=0,r=this.options.headers;n<r.length;n++){var s=r[n];i.setRequestHeader(s.name,s.value)}if(e.headers.length)for(var p=0,a=e.headers;p<a.length;p++){var s=a[p];i.setRequestHeader(s.name,s.value)}this.authToken&&i.setRequestHeader(this.authTokenHeader,this.authToken),i.send(t),this._render()},e.prototype._getTotalProgress=function(e){if(void 0===e&&(e=0),this.options.removeAfterUpload)return e;var t=this.getNotUploadedItems().length,o=t?this.queue.length-t:this.queue.length,i=100/this.queue.length,n=e*i/100;return Math.round(o*i+n)},e.prototype._getFilters=function(e){if(!e)return this.options.filters;if(Array.isArray(e))return e;if("string"==typeof e){var t=e.match(/[^\s,]+/g);return this.options.filters.filter(function(e){return-1!==t.indexOf(e.name)})}return this.options.filters},e.prototype._render=function(){},e.prototype._queueLimitFilter=function(){return void 0===this.options.queueLimit||this.queue.length<this.options.queueLimit},e.prototype._isValidFile=function(e,t,o){var i=this;return this._failFilterIndex=-1,!t.length||t.every(function(t){return i._failFilterIndex++,t.fn.call(i,e,o)})},e.prototype._isSuccessCode=function(e){return e>=200&&e<300||304===e},e.prototype._transformResponse=function(e,t){return e},e.prototype._parseHeaders=function(e){var t,o,i,n={};return e?(e.split("\n").map(function(e){i=e.indexOf(":"),t=e.slice(0,i).trim().toLowerCase(),o=e.slice(i+1).trim(),t&&(n[t]=n[t]?n[t]+", "+o:o)}),n):n},e.prototype._onWhenAddingFileFailed=function(e,t,o){this.onWhenAddingFileFailed(e,t,o)},e.prototype._onAfterAddingFile=function(e){this.onAfterAddingFile(e)},e.prototype._onAfterAddingAll=function(e){this.onAfterAddingAll(e)},e.prototype._onBeforeUploadItem=function(e){e._onBeforeUpload(),this.onBeforeUploadItem(e)},e.prototype._onBuildItemForm=function(e,t){e._onBuildForm(t),this.onBuildItemForm(e,t)},e.prototype._onProgressItem=function(e,t){var o=this._getTotalProgress(t);this.progress=o,e._onProgress(t),this.onProgressItem(e,t),this.onProgressAll(o),this._render()},e.prototype._onSuccessItem=function(e,t,o,i){e._onSuccess(t,o,i),this.onSuccessItem(e,t,o,i)},e.prototype._onCancelItem=function(e,t,o,i){e._onCancel(t,o,i),this.onCancelItem(e,t,o,i)},e}();t.FileUploader=p},function(t,o){t.exports=e},function(e,t,o){"use strict";var i=this&&this.__decorate||function(e,t,o,i){var n,r=arguments.length,s=r<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,o):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,o,i);else for(var p=e.length-1;p>=0;p--)(n=e[p])&&(s=(r<3?n(s):r>3?n(t,o,s):n(t,o))||s);return r>3&&s&&Object.defineProperty(t,o,s),s},n=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},r=o(2),s=o(1),p=function(){function e(e){this.fileOver=new r.EventEmitter,this.onFileDrop=new r.EventEmitter,this.element=e}return e.prototype.getOptions=function(){return this.uploader.options},e.prototype.getFilters=function(){return{}},e.prototype.onDrop=function(e){var t=this._getTransfer(e);if(t){var o=this.getOptions(),i=this.getFilters();this._preventAndStop(e),this.uploader.addToQueue(t.files,o,i),this.fileOver.emit(!1),this.onFileDrop.emit(t.files)}},e.prototype.onDragOver=function(e){var t=this._getTransfer(e);this._haveFiles(t.types)&&(t.dropEffect="copy",this._preventAndStop(e),this.fileOver.emit(!0))},e.prototype.onDragLeave=function(e){this.element&&e.currentTarget===this.element[0]||(this._preventAndStop(e),this.fileOver.emit(!1))},e.prototype._getTransfer=function(e){return e.dataTransfer?e.dataTransfer:e.originalEvent.dataTransfer},e.prototype._preventAndStop=function(e){e.preventDefault(),e.stopPropagation()},e.prototype._haveFiles=function(e){return!!e&&(e.indexOf?-1!==e.indexOf("Files"):!!e.contains&&e.contains("Files"))},e}();i([r.Input(),n("design:type",s.FileUploader)],p.prototype,"uploader",void 0),i([r.Output(),n("design:type",r.EventEmitter)],p.prototype,"fileOver",void 0),i([r.Output(),n("design:type",r.EventEmitter)],p.prototype,"onFileDrop",void 0),i([r.HostListener("drop",["$event"]),n("design:type",Function),n("design:paramtypes",[Object]),n("design:returntype",void 0)],p.prototype,"onDrop",null),i([r.HostListener("dragover",["$event"]),n("design:type",Function),n("design:paramtypes",[Object]),n("design:returntype",void 0)],p.prototype,"onDragOver",null),i([r.HostListener("dragleave",["$event"]),n("design:type",Function),n("design:paramtypes",[Object]),n("design:returntype",Object)],p.prototype,"onDragLeave",null),p=i([r.Directive({selector:"[ng2FileDrop]"}),n("design:paramtypes",[r.ElementRef])],p),t.FileDropDirective=p},function(e,t,o){"use strict";var i=o(0),n=function(){function e(e,t,o){this.url="/",this.headers=[],this.withCredentials=!0,this.formData=[],this.isReady=!1,this.isUploading=!1,this.isUploaded=!1,this.isSuccess=!1,this.isCancel=!1,this.isError=!1,this.progress=0,this.index=void 0,this.uploader=e,this.some=t,this.options=o,this.file=new i.FileLikeObject(t),this._file=t,e.options&&(this.method=e.options.method||"POST",this.alias=e.options.itemAlias||"file"),this.url=e.options.url}return e.prototype.upload=function(){try{this.uploader.uploadItem(this)}catch(e){this.uploader._onCompleteItem(this,"",0,{}),this.uploader._onErrorItem(this,"",0,{})}},e.prototype.cancel=function(){this.uploader.cancelItem(this)},e.prototype.remove=function(){this.uploader.removeFromQueue(this)},e.prototype.onBeforeUpload=function(){},e.prototype.onBuildForm=function(e){return{form:e}},e.prototype.onProgress=function(e){return{progress:e}},e.prototype.onSuccess=function(e,t,o){return{response:e,status:t,headers:o}},e.prototype.onError=function(e,t,o){return{response:e,status:t,headers:o}},e.prototype.onCancel=function(e,t,o){return{response:e,status:t,headers:o}},e.prototype.onComplete=function(e,t,o){return{response:e,status:t,headers:o}},e.prototype._onBeforeUpload=function(){this.isReady=!0,this.isUploading=!0,this.isUploaded=!1,this.isSuccess=!1,this.isCancel=!1,this.isError=!1,this.progress=0,this.onBeforeUpload()},e.prototype._onBuildForm=function(e){this.onBuildForm(e)},e.prototype._onProgress=function(e){this.progress=e,this.onProgress(e)},e.prototype._onSuccess=function(e,t,o){this.isReady=!1,this.isUploading=!1,this.isUploaded=!0,this.isSuccess=!0,this.isCancel=!1,this.isError=!1,this.progress=100,this.index=void 0,this.onSuccess(e,t,o)},e.prototype._onError=function(e,t,o){this.isReady=!1,this.isUploading=!1,this.isUploaded=!0,this.isSuccess=!1,this.isCancel=!1,this.isError=!0,this.progress=0,this.index=void 0,this.onError(e,t,o)},e.prototype._onCancel=function(e,t,o){this.isReady=!1,this.isUploading=!1,this.isUploaded=!1,this.isSuccess=!1,this.isCancel=!0,this.isError=!1,this.progress=0,this.index=void 0,this.onCancel(e,t,o)},e.prototype._onComplete=function(e,t,o){this.onComplete(e,t,o),this.uploader.options.removeAfterUpload&&this.remove()},e.prototype._prepareToUploading=function(){this.index=this.index||++this.uploader._nextIndex,this.isReady=!0},e}();t.FileItem=n},function(e,t,o){"use strict";var i=this&&this.__decorate||function(e,t,o,i){var n,r=arguments.length,s=r<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,o):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,o,i);else for(var p=e.length-1;p>=0;p--)(n=e[p])&&(s=(r<3?n(s):r>3?n(t,o,s):n(t,o))||s);return r>3&&s&&Object.defineProperty(t,o,s),s},n=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},r=o(2),s=o(1),p=function(){function e(e){this.element=e}return e.prototype.getOptions=function(){return this.uploader.options},e.prototype.getFilters=function(){},e.prototype.isEmptyAfterSelection=function(){return!!this.element.nativeElement.attributes.multiple},e.prototype.onChange=function(){var e=this.element.nativeElement.files,t=this.getOptions(),o=this.getFilters();this.uploader.addToQueue(e,t,o),this.isEmptyAfterSelection()&&(this.element.nativeElement.value="")},e}();i([r.Input(),n("design:type",s.FileUploader)],p.prototype,"uploader",void 0),i([r.HostListener("change"),n("design:type",Function),n("design:paramtypes",[]),n("design:returntype",Object)],p.prototype,"onChange",null),p=i([r.Directive({selector:"[ng2FileSelect]"}),n("design:paramtypes",[r.ElementRef])],p),t.FileSelectDirective=p},function(e,t,o){"use strict";var i=this&&this.__decorate||function(e,t,o,i){var n,r=arguments.length,s=r<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,o):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,o,i);else for(var p=e.length-1;p>=0;p--)(n=e[p])&&(s=(r<3?n(s):r>3?n(t,o,s):n(t,o))||s);return r>3&&s&&Object.defineProperty(t,o,s),s},n=o(8),r=o(2),s=o(3),p=o(5),a=function(){function e(){}return e}();a=i([r.NgModule({imports:[n.CommonModule],declarations:[s.FileDropDirective,p.FileSelectDirective],exports:[s.FileDropDirective,p.FileSelectDirective]})],a),t.FileUploadModule=a},function(e,t,o){"use strict";var i=function(){function e(){}return e.getMimeClass=function(e){var t="application";return-1!==this.mime_psd.indexOf(e.type)?t="image":e.type.match("image.*")?t="image":e.type.match("video.*")?t="video":e.type.match("audio.*")?t="audio":"application/pdf"===e.type?t="pdf":-1!==this.mime_compress.indexOf(e.type)?t="compress":-1!==this.mime_doc.indexOf(e.type)?t="doc":-1!==this.mime_xsl.indexOf(e.type)?t="xls":-1!==this.mime_ppt.indexOf(e.type)&&(t="ppt"),"application"===t&&(t=this.fileTypeDetection(e.name)),t},e.fileTypeDetection=function(e){var t={jpg:"image",jpeg:"image",tif:"image",psd:"image",bmp:"image",png:"image",nef:"image",tiff:"image",cr2:"image",dwg:"image",cdr:"image",ai:"image",indd:"image",pin:"image",cdp:"image",skp:"image",stp:"image","3dm":"image",mp3:"audio",wav:"audio",wma:"audio",mod:"audio",m4a:"audio",compress:"compress",rar:"compress","7z":"compress",lz:"compress",z01:"compress",pdf:"pdf",xls:"xls",xlsx:"xls",ods:"xls",mp4:"video",avi:"video",wmv:"video",mpg:"video",mts:"video",flv:"video","3gp":"video",vob:"video",m4v:"video",mpeg:"video",m2ts:"video",mov:"video",doc:"doc",docx:"doc",eps:"doc",txt:"doc",odt:"doc",rtf:"doc",ppt:"ppt",pptx:"ppt",pps:"ppt",ppsx:"ppt",odp:"ppt"},o=e.split(".");if(o.length<2)return"application";var i=o[o.length-1].toLowerCase();return void 0===t[i]?"application":t[i]},e}();i.mime_doc=["application/msword","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.openxmlformats-officedocument.wordprocessingml.template","application/vnd.ms-word.document.macroEnabled.12","application/vnd.ms-word.template.macroEnabled.12"],i.mime_xsl=["application/vnd.ms-excel","application/vnd.ms-excel","application/vnd.ms-excel","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.openxmlformats-officedocument.spreadsheetml.template","application/vnd.ms-excel.sheet.macroEnabled.12","application/vnd.ms-excel.template.macroEnabled.12","application/vnd.ms-excel.addin.macroEnabled.12","application/vnd.ms-excel.sheet.binary.macroEnabled.12"],i.mime_ppt=["application/vnd.ms-powerpoint","application/vnd.ms-powerpoint","application/vnd.ms-powerpoint","application/vnd.ms-powerpoint","application/vnd.openxmlformats-officedocument.presentationml.presentation","application/vnd.openxmlformats-officedocument.presentationml.template","application/vnd.openxmlformats-officedocument.presentationml.slideshow","application/vnd.ms-powerpoint.addin.macroEnabled.12","application/vnd.ms-powerpoint.presentation.macroEnabled.12","application/vnd.ms-powerpoint.presentation.macroEnabled.12","application/vnd.ms-powerpoint.slideshow.macroEnabled.12"],i.mime_psd=["image/photoshop","image/x-photoshop","image/psd","application/photoshop","application/psd","zz-application/zz-winassoc-psd"],i.mime_compress=["application/x-gtar","application/x-gcompress","application/compress","application/x-tar","application/x-rar-compressed","application/octet-stream"],t.FileType=i},function(e,o){e.exports=t},function(e,t,o){"use strict";function i(e){for(var o in e)t.hasOwnProperty(o)||(t[o]=e[o])}i(o(5)),i(o(3)),i(o(1)),i(o(4)),i(o(0));var n=o(6);t.FileUploadModule=n.FileUploadModule}])}); | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@angular/core"),require("@angular/common")):"function"==typeof define&&define.amd?define(["@angular/core","@angular/common"],t):"object"==typeof exports?exports["ng2-file-upload.umd.min"]=t(require("@angular/core"),require("@angular/common")):e["ng2-file-upload.umd.min"]=t(e["@angular/core"],e["@angular/common"])}(this,function(e,t){return function(e){function t(i){if(o[i])return o[i].exports;var n=o[i]={i:i,l:!1,exports:{}};return e[i].call(n.exports,n,n.exports,t),n.l=!0,n.exports}var o={};return t.m=e,t.c=o,t.i=function(e){return e},t.d=function(e,o,i){t.o(e,o)||Object.defineProperty(e,o,{configurable:!1,enumerable:!0,get:i})},t.n=function(e){var o=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(o,"a",o),o},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="/",t(t.s=9)}([function(t,o){t.exports=e},function(e,t,o){"use strict";function i(e){return!(!e||!(e.nodeName||e.prop&&e.attr&&e.find))}var n=function(){function e(e){this.rawFile=e;var t=i(e),o=t?e.value:e;this["_createFrom"+("string"==typeof o?"FakePath":"Object")](o)}return e.prototype._createFromFakePath=function(e){this.lastModifiedDate=void 0,this.size=void 0,this.type="like/"+e.slice(e.lastIndexOf(".")+1).toLowerCase(),this.name=e.slice(e.lastIndexOf("/")+e.lastIndexOf("\\")+2)},e.prototype._createFromObject=function(e){this.size=e.size,this.type=e.type,this.name=e.name},e}();t.FileLikeObject=n},function(e,t,o){"use strict";function i(e){return File&&e instanceof File}var n=o(0),r=o(1),s=o(4),p=o(7),a=function(){function e(e){this.isUploading=!1,this.queue=[],this.progress=0,this._nextIndex=0,this.options={autoUpload:!1,isHTML5:!0,filters:[],removeAfterUpload:!1,disableMultipart:!1,formatDataFunction:function(e){return e._file},formatDataFunctionIsAsync:!1},this.setOptions(e),this.response=new n.EventEmitter}return e.prototype.setOptions=function(e){this.options=Object.assign(this.options,e),this.authToken=this.options.authToken,this.authTokenHeader=this.options.authTokenHeader||"Authorization",this.autoUpload=this.options.autoUpload,this.options.filters.unshift({name:"queueLimit",fn:this._queueLimitFilter}),this.options.maxFileSize&&this.options.filters.unshift({name:"fileSize",fn:this._fileSizeFilter}),this.options.allowedFileType&&this.options.filters.unshift({name:"fileType",fn:this._fileTypeFilter}),this.options.allowedMimeType&&this.options.filters.unshift({name:"mimeType",fn:this._mimeTypeFilter});for(var t=0;t<this.queue.length;t++)this.queue[t].url=this.options.url},e.prototype.addToQueue=function(e,t,o){for(var i=this,n=[],p=0,a=e;p<a.length;p++){var l=a[p];n.push(l)}var u=this._getFilters(o),c=this.queue.length,d=[];n.map(function(e){t||(t=i.options);var o=new r.FileLikeObject(e);if(i._isValidFile(o,u,t)){var n=new s.FileItem(i,e,t);d.push(n),i.queue.push(n),i._onAfterAddingFile(n)}else{var p=u[i._failFilterIndex];i._onWhenAddingFileFailed(o,p,t)}}),this.queue.length!==c&&(this._onAfterAddingAll(d),this.progress=this._getTotalProgress()),this._render(),this.options.autoUpload&&this.uploadAll()},e.prototype.removeFromQueue=function(e){var t=this.getIndexOfItem(e),o=this.queue[t];o.isUploading&&o.cancel(),this.queue.splice(t,1),this.progress=this._getTotalProgress()},e.prototype.clearQueue=function(){for(;this.queue.length;)this.queue[0].remove();this.progress=0},e.prototype.uploadItem=function(e){var t=this.getIndexOfItem(e),o=this.queue[t],i=this.options.isHTML5?"_xhrTransport":"_iframeTransport";o._prepareToUploading(),this.isUploading||(this.isUploading=!0,this[i](o))},e.prototype.cancelItem=function(e){var t=this.getIndexOfItem(e),o=this.queue[t],i=this.options.isHTML5?o._xhr:o._form;o&&o.isUploading&&i.abort()},e.prototype.uploadAll=function(){var e=this.getNotUploadedItems().filter(function(e){return!e.isUploading});e.length&&(e.map(function(e){return e._prepareToUploading()}),e[0].upload())},e.prototype.cancelAll=function(){this.getNotUploadedItems().map(function(e){return e.cancel()})},e.prototype.isFile=function(e){return i(e)},e.prototype.isFileLikeObject=function(e){return e instanceof r.FileLikeObject},e.prototype.getIndexOfItem=function(e){return"number"==typeof e?e:this.queue.indexOf(e)},e.prototype.getNotUploadedItems=function(){return this.queue.filter(function(e){return!e.isUploaded})},e.prototype.getReadyItems=function(){return this.queue.filter(function(e){return e.isReady&&!e.isUploading}).sort(function(e,t){return e.index-t.index})},e.prototype.destroy=function(){},e.prototype.onAfterAddingAll=function(e){return{fileItems:e}},e.prototype.onBuildItemForm=function(e,t){return{fileItem:e,form:t}},e.prototype.onAfterAddingFile=function(e){return{fileItem:e}},e.prototype.onWhenAddingFileFailed=function(e,t,o){return{item:e,filter:t,options:o}},e.prototype.onBeforeUploadItem=function(e){return{fileItem:e}},e.prototype.onProgressItem=function(e,t){return{fileItem:e,progress:t}},e.prototype.onProgressAll=function(e){return{progress:e}},e.prototype.onSuccessItem=function(e,t,o,i){return{item:e,response:t,status:o,headers:i}},e.prototype.onErrorItem=function(e,t,o,i){return{item:e,response:t,status:o,headers:i}},e.prototype.onCancelItem=function(e,t,o,i){return{item:e,response:t,status:o,headers:i}},e.prototype.onCompleteItem=function(e,t,o,i){return{item:e,response:t,status:o,headers:i}},e.prototype.onCompleteAll=function(){},e.prototype._mimeTypeFilter=function(e){return!(this.options.allowedMimeType&&-1===this.options.allowedMimeType.indexOf(e.type))},e.prototype._fileSizeFilter=function(e){return!(this.options.maxFileSize&&e.size>this.options.maxFileSize)},e.prototype._fileTypeFilter=function(e){return!(this.options.allowedFileType&&-1===this.options.allowedFileType.indexOf(p.FileType.getMimeClass(e)))},e.prototype._onErrorItem=function(e,t,o,i){e._onError(t,o,i),this.onErrorItem(e,t,o,i)},e.prototype._onCompleteItem=function(e,t,o,i){e._onComplete(t,o,i),this.onCompleteItem(e,t,o,i);var n=this.getReadyItems()[0];if(this.isUploading=!1,n)return void n.upload();this.onCompleteAll(),this.progress=this._getTotalProgress(),this._render()},e.prototype._headersGetter=function(e){return function(t){return t?e[t.toLowerCase()]||void 0:e}},e.prototype._xhrTransport=function(e){var t,o=this,i=this,n=e._xhr=new XMLHttpRequest;if(this._onBeforeUploadItem(e),"number"!=typeof e._file.size)throw new TypeError("The file specified is no longer valid");if(this.options.disableMultipart)t=this.options.formatDataFunction(e);else{t=new FormData,this._onBuildItemForm(e,t);var r=function(){return t.append(e.alias,e._file,e.file.name)};this.options.parametersBeforeFiles||r(),void 0!==this.options.additionalParameter&&Object.keys(this.options.additionalParameter).forEach(function(i){var n=o.options.additionalParameter[i];"string"==typeof n&&n.indexOf("{{file_name}}")>=0&&(n=n.replace("{{file_name}}",e.file.name)),t.append(i,n)}),this.options.parametersBeforeFiles&&r()}if(n.upload.onprogress=function(t){var i=Math.round(t.lengthComputable?100*t.loaded/t.total:0);o._onProgressItem(e,i)},n.onload=function(){var t=o._parseHeaders(n.getAllResponseHeaders()),i=o._transformResponse(n.response,t),r=o._isSuccessCode(n.status)?"Success":"Error";o["_on"+r+"Item"](e,i,n.status,t),o._onCompleteItem(e,i,n.status,t)},n.onerror=function(){var t=o._parseHeaders(n.getAllResponseHeaders()),i=o._transformResponse(n.response,t);o._onErrorItem(e,i,n.status,t),o._onCompleteItem(e,i,n.status,t)},n.onabort=function(){var t=o._parseHeaders(n.getAllResponseHeaders()),i=o._transformResponse(n.response,t);o._onCancelItem(e,i,n.status,t),o._onCompleteItem(e,i,n.status,t)},n.open(e.method,e.url,!0),n.withCredentials=e.withCredentials,this.options.headers)for(var s=0,p=this.options.headers;s<p.length;s++){var a=p[s];n.setRequestHeader(a.name,a.value)}if(e.headers.length)for(var l=0,u=e.headers;l<u.length;l++){var a=u[l];n.setRequestHeader(a.name,a.value)}this.authToken&&n.setRequestHeader(this.authTokenHeader,this.authToken),n.onreadystatechange=function(){n.readyState==XMLHttpRequest.DONE&&i.response.emit(n.responseText)},this.options.formatDataFunctionIsAsync?t.then(function(e){return n.send(JSON.stringify(e))}):n.send(t),this._render()},e.prototype._getTotalProgress=function(e){if(void 0===e&&(e=0),this.options.removeAfterUpload)return e;var t=this.getNotUploadedItems().length,o=t?this.queue.length-t:this.queue.length,i=100/this.queue.length,n=e*i/100;return Math.round(o*i+n)},e.prototype._getFilters=function(e){if(!e)return this.options.filters;if(Array.isArray(e))return e;if("string"==typeof e){var t=e.match(/[^\s,]+/g);return this.options.filters.filter(function(e){return-1!==t.indexOf(e.name)})}return this.options.filters},e.prototype._render=function(){},e.prototype._queueLimitFilter=function(){return void 0===this.options.queueLimit||this.queue.length<this.options.queueLimit},e.prototype._isValidFile=function(e,t,o){var i=this;return this._failFilterIndex=-1,!t.length||t.every(function(t){return i._failFilterIndex++,t.fn.call(i,e,o)})},e.prototype._isSuccessCode=function(e){return e>=200&&e<300||304===e},e.prototype._transformResponse=function(e,t){return e},e.prototype._parseHeaders=function(e){var t,o,i,n={};return e?(e.split("\n").map(function(e){i=e.indexOf(":"),t=e.slice(0,i).trim().toLowerCase(),o=e.slice(i+1).trim(),t&&(n[t]=n[t]?n[t]+", "+o:o)}),n):n},e.prototype._onWhenAddingFileFailed=function(e,t,o){this.onWhenAddingFileFailed(e,t,o)},e.prototype._onAfterAddingFile=function(e){this.onAfterAddingFile(e)},e.prototype._onAfterAddingAll=function(e){this.onAfterAddingAll(e)},e.prototype._onBeforeUploadItem=function(e){e._onBeforeUpload(),this.onBeforeUploadItem(e)},e.prototype._onBuildItemForm=function(e,t){e._onBuildForm(t),this.onBuildItemForm(e,t)},e.prototype._onProgressItem=function(e,t){var o=this._getTotalProgress(t);this.progress=o,e._onProgress(t),this.onProgressItem(e,t),this.onProgressAll(o),this._render()},e.prototype._onSuccessItem=function(e,t,o,i){e._onSuccess(t,o,i),this.onSuccessItem(e,t,o,i)},e.prototype._onCancelItem=function(e,t,o,i){e._onCancel(t,o,i),this.onCancelItem(e,t,o,i)},e}();t.FileUploader=a},function(e,t,o){"use strict";var i=this&&this.__decorate||function(e,t,o,i){var n,r=arguments.length,s=r<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,o):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,o,i);else for(var p=e.length-1;p>=0;p--)(n=e[p])&&(s=(r<3?n(s):r>3?n(t,o,s):n(t,o))||s);return r>3&&s&&Object.defineProperty(t,o,s),s},n=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},r=o(0),s=o(2),p=function(){function e(e){this.fileOver=new r.EventEmitter,this.onFileDrop=new r.EventEmitter,this.element=e}return e.prototype.getOptions=function(){return this.uploader.options},e.prototype.getFilters=function(){return{}},e.prototype.onDrop=function(e){var t=this._getTransfer(e);if(t){var o=this.getOptions(),i=this.getFilters();this._preventAndStop(e),this.uploader.addToQueue(t.files,o,i),this.fileOver.emit(!1),this.onFileDrop.emit(t.files)}},e.prototype.onDragOver=function(e){var t=this._getTransfer(e);this._haveFiles(t.types)&&(t.dropEffect="copy",this._preventAndStop(e),this.fileOver.emit(!0))},e.prototype.onDragLeave=function(e){this.element&&e.currentTarget===this.element[0]||(this._preventAndStop(e),this.fileOver.emit(!1))},e.prototype._getTransfer=function(e){return e.dataTransfer?e.dataTransfer:e.originalEvent.dataTransfer},e.prototype._preventAndStop=function(e){e.preventDefault(),e.stopPropagation()},e.prototype._haveFiles=function(e){return!!e&&(e.indexOf?-1!==e.indexOf("Files"):!!e.contains&&e.contains("Files"))},e}();i([r.Input(),n("design:type",s.FileUploader)],p.prototype,"uploader",void 0),i([r.Output(),n("design:type",r.EventEmitter)],p.prototype,"fileOver",void 0),i([r.Output(),n("design:type",r.EventEmitter)],p.prototype,"onFileDrop",void 0),i([r.HostListener("drop",["$event"]),n("design:type",Function),n("design:paramtypes",[Object]),n("design:returntype",void 0)],p.prototype,"onDrop",null),i([r.HostListener("dragover",["$event"]),n("design:type",Function),n("design:paramtypes",[Object]),n("design:returntype",void 0)],p.prototype,"onDragOver",null),i([r.HostListener("dragleave",["$event"]),n("design:type",Function),n("design:paramtypes",[Object]),n("design:returntype",Object)],p.prototype,"onDragLeave",null),p=i([r.Directive({selector:"[ng2FileDrop]"}),n("design:paramtypes",[r.ElementRef])],p),t.FileDropDirective=p},function(e,t,o){"use strict";var i=o(1),n=function(){function e(e,t,o){this.url="/",this.headers=[],this.withCredentials=!0,this.formData=[],this.isReady=!1,this.isUploading=!1,this.isUploaded=!1,this.isSuccess=!1,this.isCancel=!1,this.isError=!1,this.progress=0,this.index=void 0,this.uploader=e,this.some=t,this.options=o,this.file=new i.FileLikeObject(t),this._file=t,e.options&&(this.method=e.options.method||"POST",this.alias=e.options.itemAlias||"file"),this.url=e.options.url}return e.prototype.upload=function(){try{this.uploader.uploadItem(this)}catch(e){this.uploader._onCompleteItem(this,"",0,{}),this.uploader._onErrorItem(this,"",0,{})}},e.prototype.cancel=function(){this.uploader.cancelItem(this)},e.prototype.remove=function(){this.uploader.removeFromQueue(this)},e.prototype.onBeforeUpload=function(){},e.prototype.onBuildForm=function(e){return{form:e}},e.prototype.onProgress=function(e){return{progress:e}},e.prototype.onSuccess=function(e,t,o){return{response:e,status:t,headers:o}},e.prototype.onError=function(e,t,o){return{response:e,status:t,headers:o}},e.prototype.onCancel=function(e,t,o){return{response:e,status:t,headers:o}},e.prototype.onComplete=function(e,t,o){return{response:e,status:t,headers:o}},e.prototype._onBeforeUpload=function(){this.isReady=!0,this.isUploading=!0,this.isUploaded=!1,this.isSuccess=!1,this.isCancel=!1,this.isError=!1,this.progress=0,this.onBeforeUpload()},e.prototype._onBuildForm=function(e){this.onBuildForm(e)},e.prototype._onProgress=function(e){this.progress=e,this.onProgress(e)},e.prototype._onSuccess=function(e,t,o){this.isReady=!1,this.isUploading=!1,this.isUploaded=!0,this.isSuccess=!0,this.isCancel=!1,this.isError=!1,this.progress=100,this.index=void 0,this.onSuccess(e,t,o)},e.prototype._onError=function(e,t,o){this.isReady=!1,this.isUploading=!1,this.isUploaded=!0,this.isSuccess=!1,this.isCancel=!1,this.isError=!0,this.progress=0,this.index=void 0,this.onError(e,t,o)},e.prototype._onCancel=function(e,t,o){this.isReady=!1,this.isUploading=!1,this.isUploaded=!1,this.isSuccess=!1,this.isCancel=!0,this.isError=!1,this.progress=0,this.index=void 0,this.onCancel(e,t,o)},e.prototype._onComplete=function(e,t,o){this.onComplete(e,t,o),this.uploader.options.removeAfterUpload&&this.remove()},e.prototype._prepareToUploading=function(){this.index=this.index||++this.uploader._nextIndex,this.isReady=!0},e}();t.FileItem=n},function(e,t,o){"use strict";var i=this&&this.__decorate||function(e,t,o,i){var n,r=arguments.length,s=r<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,o):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,o,i);else for(var p=e.length-1;p>=0;p--)(n=e[p])&&(s=(r<3?n(s):r>3?n(t,o,s):n(t,o))||s);return r>3&&s&&Object.defineProperty(t,o,s),s},n=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},r=o(0),s=o(2),p=function(){function e(e){this.onFileSelected=new r.EventEmitter,this.element=e}return e.prototype.getOptions=function(){return this.uploader.options},e.prototype.getFilters=function(){return{}},e.prototype.isEmptyAfterSelection=function(){return!!this.element.nativeElement.attributes.multiple},e.prototype.onChange=function(){var e=this.element.nativeElement.files,t=this.getOptions(),o=this.getFilters();this.uploader.addToQueue(e,t,o),this.onFileSelected.emit(e),this.isEmptyAfterSelection()&&(this.element.nativeElement.value="")},e}();i([r.Input(),n("design:type",s.FileUploader)],p.prototype,"uploader",void 0),i([r.Output(),n("design:type",r.EventEmitter)],p.prototype,"onFileSelected",void 0),i([r.HostListener("change"),n("design:type",Function),n("design:paramtypes",[]),n("design:returntype",Object)],p.prototype,"onChange",null),p=i([r.Directive({selector:"[ng2FileSelect]"}),n("design:paramtypes",[r.ElementRef])],p),t.FileSelectDirective=p},function(e,t,o){"use strict";var i=this&&this.__decorate||function(e,t,o,i){var n,r=arguments.length,s=r<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,o):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,o,i);else for(var p=e.length-1;p>=0;p--)(n=e[p])&&(s=(r<3?n(s):r>3?n(t,o,s):n(t,o))||s);return r>3&&s&&Object.defineProperty(t,o,s),s},n=o(8),r=o(0),s=o(3),p=o(5),a=function(){function e(){}return e}();a=i([r.NgModule({imports:[n.CommonModule],declarations:[s.FileDropDirective,p.FileSelectDirective],exports:[s.FileDropDirective,p.FileSelectDirective]})],a),t.FileUploadModule=a},function(e,t,o){"use strict";var i=function(){function e(){}return e.getMimeClass=function(e){var t="application";return-1!==this.mime_psd.indexOf(e.type)?t="image":e.type.match("image.*")?t="image":e.type.match("video.*")?t="video":e.type.match("audio.*")?t="audio":"application/pdf"===e.type?t="pdf":-1!==this.mime_compress.indexOf(e.type)?t="compress":-1!==this.mime_doc.indexOf(e.type)?t="doc":-1!==this.mime_xsl.indexOf(e.type)?t="xls":-1!==this.mime_ppt.indexOf(e.type)&&(t="ppt"),"application"===t&&(t=this.fileTypeDetection(e.name)),t},e.fileTypeDetection=function(e){var t={jpg:"image",jpeg:"image",tif:"image",psd:"image",bmp:"image",png:"image",nef:"image",tiff:"image",cr2:"image",dwg:"image",cdr:"image",ai:"image",indd:"image",pin:"image",cdp:"image",skp:"image",stp:"image","3dm":"image",mp3:"audio",wav:"audio",wma:"audio",mod:"audio",m4a:"audio",compress:"compress",zip:"compress",rar:"compress","7z":"compress",lz:"compress",z01:"compress",pdf:"pdf",xls:"xls",xlsx:"xls",ods:"xls",mp4:"video",avi:"video",wmv:"video",mpg:"video",mts:"video",flv:"video","3gp":"video",vob:"video",m4v:"video",mpeg:"video",m2ts:"video",mov:"video",doc:"doc",docx:"doc",eps:"doc",txt:"doc",odt:"doc",rtf:"doc",ppt:"ppt",pptx:"ppt",pps:"ppt",ppsx:"ppt",odp:"ppt"},o=e.split(".");if(o.length<2)return"application";var i=o[o.length-1].toLowerCase();return void 0===t[i]?"application":t[i]},e}();i.mime_doc=["application/msword","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.openxmlformats-officedocument.wordprocessingml.template","application/vnd.ms-word.document.macroEnabled.12","application/vnd.ms-word.template.macroEnabled.12"],i.mime_xsl=["application/vnd.ms-excel","application/vnd.ms-excel","application/vnd.ms-excel","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.openxmlformats-officedocument.spreadsheetml.template","application/vnd.ms-excel.sheet.macroEnabled.12","application/vnd.ms-excel.template.macroEnabled.12","application/vnd.ms-excel.addin.macroEnabled.12","application/vnd.ms-excel.sheet.binary.macroEnabled.12"],i.mime_ppt=["application/vnd.ms-powerpoint","application/vnd.ms-powerpoint","application/vnd.ms-powerpoint","application/vnd.ms-powerpoint","application/vnd.openxmlformats-officedocument.presentationml.presentation","application/vnd.openxmlformats-officedocument.presentationml.template","application/vnd.openxmlformats-officedocument.presentationml.slideshow","application/vnd.ms-powerpoint.addin.macroEnabled.12","application/vnd.ms-powerpoint.presentation.macroEnabled.12","application/vnd.ms-powerpoint.presentation.macroEnabled.12","application/vnd.ms-powerpoint.slideshow.macroEnabled.12"],i.mime_psd=["image/photoshop","image/x-photoshop","image/psd","application/photoshop","application/psd","zz-application/zz-winassoc-psd"],i.mime_compress=["application/x-gtar","application/x-gcompress","application/compress","application/x-tar","application/x-rar-compressed","application/octet-stream"],t.FileType=i},function(e,o){e.exports=t},function(e,t,o){"use strict";function i(e){for(var o in e)t.hasOwnProperty(o)||(t[o]=e[o])}i(o(5)),i(o(3)),i(o(2)),i(o(4)),i(o(1));var n=o(6);t.FileUploadModule=n.FileUploadModule}])}); |
@@ -0,1 +1,16 @@ | ||
<a name="1.3.0"></a> | ||
# [1.3.0](https://github.com/valor-software/ng2-file-upload/compare/v1.2.0...v1.3.0) (2017-11-25) | ||
### Features | ||
* **file-upload:** Add response and function to modify the request body ([#901](https://github.com/valor-software/ng2-file-upload/pull/901)) | ||
* **file-upload** add file type .zip ([#911](https://github.com/valor-software/ng2-file-upload/pull/911)) | ||
### Bug Fixes | ||
* **file-uploader** Update: setOptions ([#904](https://github.com/valor-software/ng2-file-upload/pull/904)) | ||
* **docs** Fix correct path for isHTML5 option ([#844](https://github.com/valor-software/ng2-file-upload/pull/844)) | ||
* **docs** Added onFileDrop() event to documentation ([#857](https://github.com/valor-software/ng2-file-upload/pull/857)) | ||
<a name="1.2.1"></a> | ||
@@ -2,0 +17,0 @@ ## [1.2.1](https://github.com/valor-software/ng2-file-upload/compare/v1.2.0...v1.2.1) (2017-04-10) |
import { EventEmitter, ElementRef } from '@angular/core'; | ||
import { FileUploader } from './file-uploader.class'; | ||
import { FileUploader, FileUploaderOptions } from './file-uploader.class'; | ||
export declare class FileDropDirective { | ||
@@ -9,3 +9,3 @@ uploader: FileUploader; | ||
constructor(element: ElementRef); | ||
getOptions(): any; | ||
getOptions(): FileUploaderOptions; | ||
getFilters(): any; | ||
@@ -12,0 +12,0 @@ onDrop(event: any): void; |
@@ -1,1 +0,1 @@ | ||
[{"__symbolic":"module","version":3,"metadata":{"FileItem":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"./file-uploader.class","name":"FileUploader"},{"__symbolic":"error","message":"Could not resolve type","line":27,"character":49,"context":{"typeName":"File"}},{"__symbolic":"reference","module":"./file-uploader.class","name":"FileUploaderOptions"}]}],"upload":[{"__symbolic":"method"}],"cancel":[{"__symbolic":"method"}],"remove":[{"__symbolic":"method"}],"onBeforeUpload":[{"__symbolic":"method"}],"onBuildForm":[{"__symbolic":"method"}],"onProgress":[{"__symbolic":"method"}],"onSuccess":[{"__symbolic":"method"}],"onError":[{"__symbolic":"method"}],"onCancel":[{"__symbolic":"method"}],"onComplete":[{"__symbolic":"method"}],"_onBeforeUpload":[{"__symbolic":"method"}],"_onBuildForm":[{"__symbolic":"method"}],"_onProgress":[{"__symbolic":"method"}],"_onSuccess":[{"__symbolic":"method"}],"_onError":[{"__symbolic":"method"}],"_onCancel":[{"__symbolic":"method"}],"_onComplete":[{"__symbolic":"method"}],"_prepareToUploading":[{"__symbolic":"method"}]}}}},{"__symbolic":"module","version":1,"metadata":{"FileItem":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"./file-uploader.class","name":"FileUploader"},{"__symbolic":"error","message":"Could not resolve type","line":27,"character":49,"context":{"typeName":"File"}},{"__symbolic":"reference","module":"./file-uploader.class","name":"FileUploaderOptions"}]}],"upload":[{"__symbolic":"method"}],"cancel":[{"__symbolic":"method"}],"remove":[{"__symbolic":"method"}],"onBeforeUpload":[{"__symbolic":"method"}],"onBuildForm":[{"__symbolic":"method"}],"onProgress":[{"__symbolic":"method"}],"onSuccess":[{"__symbolic":"method"}],"onError":[{"__symbolic":"method"}],"onCancel":[{"__symbolic":"method"}],"onComplete":[{"__symbolic":"method"}],"_onBeforeUpload":[{"__symbolic":"method"}],"_onBuildForm":[{"__symbolic":"method"}],"_onProgress":[{"__symbolic":"method"}],"_onSuccess":[{"__symbolic":"method"}],"_onError":[{"__symbolic":"method"}],"_onCancel":[{"__symbolic":"method"}],"_onComplete":[{"__symbolic":"method"}],"_prepareToUploading":[{"__symbolic":"method"}]}}}}] | ||
[{"__symbolic":"module","version":3,"metadata":{"FileItem":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"./file-uploader.class","name":"FileUploader"},{"__symbolic":"error","message":"Could not resolve type","line":27,"character":51,"context":{"typeName":"File"}},{"__symbolic":"reference","module":"./file-uploader.class","name":"FileUploaderOptions"}]}],"upload":[{"__symbolic":"method"}],"cancel":[{"__symbolic":"method"}],"remove":[{"__symbolic":"method"}],"onBeforeUpload":[{"__symbolic":"method"}],"onBuildForm":[{"__symbolic":"method"}],"onProgress":[{"__symbolic":"method"}],"onSuccess":[{"__symbolic":"method"}],"onError":[{"__symbolic":"method"}],"onCancel":[{"__symbolic":"method"}],"onComplete":[{"__symbolic":"method"}],"_onBeforeUpload":[{"__symbolic":"method"}],"_onBuildForm":[{"__symbolic":"method"}],"_onProgress":[{"__symbolic":"method"}],"_onSuccess":[{"__symbolic":"method"}],"_onError":[{"__symbolic":"method"}],"_onCancel":[{"__symbolic":"method"}],"_onComplete":[{"__symbolic":"method"}],"_prepareToUploading":[{"__symbolic":"method"}]}}}},{"__symbolic":"module","version":1,"metadata":{"FileItem":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"./file-uploader.class","name":"FileUploader"},{"__symbolic":"error","message":"Could not resolve type","line":27,"character":51,"context":{"typeName":"File"}},{"__symbolic":"reference","module":"./file-uploader.class","name":"FileUploaderOptions"}]}],"upload":[{"__symbolic":"method"}],"cancel":[{"__symbolic":"method"}],"remove":[{"__symbolic":"method"}],"onBeforeUpload":[{"__symbolic":"method"}],"onBuildForm":[{"__symbolic":"method"}],"onProgress":[{"__symbolic":"method"}],"onSuccess":[{"__symbolic":"method"}],"onError":[{"__symbolic":"method"}],"onCancel":[{"__symbolic":"method"}],"onComplete":[{"__symbolic":"method"}],"_onBeforeUpload":[{"__symbolic":"method"}],"_onBuildForm":[{"__symbolic":"method"}],"_onProgress":[{"__symbolic":"method"}],"_onSuccess":[{"__symbolic":"method"}],"_onError":[{"__symbolic":"method"}],"_onCancel":[{"__symbolic":"method"}],"_onComplete":[{"__symbolic":"method"}],"_prepareToUploading":[{"__symbolic":"method"}]}}}}] |
@@ -6,2 +6,3 @@ export declare class FileLikeObject { | ||
name: string; | ||
rawFile: string; | ||
constructor(fileOrInput: any); | ||
@@ -8,0 +9,0 @@ _createFromFakePath(path: string): void; |
@@ -7,2 +7,3 @@ "use strict"; | ||
function FileLikeObject(fileOrInput) { | ||
this.rawFile = fileOrInput; | ||
var isInput = isElement(fileOrInput); | ||
@@ -21,3 +22,2 @@ var fakePathOrObject = isInput ? fileOrInput.value : fileOrInput; | ||
FileLikeObject.prototype._createFromObject = function (object) { | ||
// this.lastModifiedDate = copy(object.lastModifiedDate); | ||
this.size = object.size; | ||
@@ -24,0 +24,0 @@ this.type = object.type; |
@@ -1,5 +0,6 @@ | ||
import { ElementRef } from '@angular/core'; | ||
import { EventEmitter, ElementRef } from '@angular/core'; | ||
import { FileUploader } from './file-uploader.class'; | ||
export declare class FileSelectDirective { | ||
uploader: FileUploader; | ||
onFileSelected: EventEmitter<File[]>; | ||
protected element: ElementRef; | ||
@@ -6,0 +7,0 @@ constructor(element: ElementRef); |
@@ -13,5 +13,5 @@ "use strict"; | ||
var file_uploader_class_1 = require("./file-uploader.class"); | ||
// todo: filters | ||
var FileSelectDirective = (function () { | ||
function FileSelectDirective(element) { | ||
this.onFileSelected = new core_1.EventEmitter(); | ||
this.element = element; | ||
@@ -23,3 +23,3 @@ } | ||
FileSelectDirective.prototype.getFilters = function () { | ||
return void 0; | ||
return {}; | ||
}; | ||
@@ -30,10 +30,8 @@ FileSelectDirective.prototype.isEmptyAfterSelection = function () { | ||
FileSelectDirective.prototype.onChange = function () { | ||
// let files = this.uploader.isHTML5 ? this.element.nativeElement[0].files : this.element.nativeElement[0]; | ||
var files = this.element.nativeElement.files; | ||
var options = this.getOptions(); | ||
var filters = this.getFilters(); | ||
// if(!this.uploader.isHTML5) this.destroy(); | ||
this.uploader.addToQueue(files, options, filters); | ||
this.onFileSelected.emit(files); | ||
if (this.isEmptyAfterSelection()) { | ||
// todo | ||
this.element.nativeElement.value = ''; | ||
@@ -49,2 +47,6 @@ } | ||
__decorate([ | ||
core_1.Output(), | ||
__metadata("design:type", core_1.EventEmitter) | ||
], FileSelectDirective.prototype, "onFileSelected", void 0); | ||
__decorate([ | ||
core_1.HostListener('change'), | ||
@@ -51,0 +53,0 @@ __metadata("design:type", Function), |
@@ -1,1 +0,1 @@ | ||
[{"__symbolic":"module","version":3,"metadata":{"FileSelectDirective":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Directive"},"arguments":[{"selector":"[ng2FileSelect]"}]}],"members":{"uploader":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@angular/core","name":"ElementRef"}]}],"getOptions":[{"__symbolic":"method"}],"getFilters":[{"__symbolic":"method"}],"isEmptyAfterSelection":[{"__symbolic":"method"}],"onChange":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"HostListener"},"arguments":["change"]}]}]}}}},{"__symbolic":"module","version":1,"metadata":{"FileSelectDirective":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Directive"},"arguments":[{"selector":"[ng2FileSelect]"}]}],"members":{"uploader":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@angular/core","name":"ElementRef"}]}],"getOptions":[{"__symbolic":"method"}],"getFilters":[{"__symbolic":"method"}],"isEmptyAfterSelection":[{"__symbolic":"method"}],"onChange":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"HostListener"},"arguments":["change"]}]}]}}}}] | ||
[{"__symbolic":"module","version":3,"metadata":{"FileSelectDirective":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Directive"},"arguments":[{"selector":"[ng2FileSelect]"}]}],"members":{"uploader":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"onFileSelected":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Output"}}]}],"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@angular/core","name":"ElementRef"}]}],"getOptions":[{"__symbolic":"method"}],"getFilters":[{"__symbolic":"method"}],"isEmptyAfterSelection":[{"__symbolic":"method"}],"onChange":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"HostListener"},"arguments":["change"]}]}]}}}},{"__symbolic":"module","version":1,"metadata":{"FileSelectDirective":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Directive"},"arguments":[{"selector":"[ng2FileSelect]"}]}],"members":{"uploader":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"onFileSelected":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Output"}}]}],"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@angular/core","name":"ElementRef"}]}],"getOptions":[{"__symbolic":"method"}],"getFilters":[{"__symbolic":"method"}],"isEmptyAfterSelection":[{"__symbolic":"method"}],"onChange":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"HostListener"},"arguments":["change"]}]}]}}}}] |
@@ -65,2 +65,3 @@ "use strict"; | ||
'compress': 'compress', | ||
'zip': 'compress', | ||
'rar': 'compress', | ||
@@ -67,0 +68,0 @@ '7z': 'compress', |
@@ -0,1 +1,2 @@ | ||
import { EventEmitter } from '@angular/core'; | ||
import { FileLikeObject } from './file-like-object.class'; | ||
@@ -15,8 +16,8 @@ import { FileItem } from './file-item.class'; | ||
export interface FileUploaderOptions { | ||
allowedMimeType?: Array<string>; | ||
allowedFileType?: Array<string>; | ||
allowedMimeType?: string[]; | ||
allowedFileType?: string[]; | ||
autoUpload?: boolean; | ||
isHTML5?: boolean; | ||
filters?: Array<FilterFunction>; | ||
headers?: Array<Headers>; | ||
filters?: FilterFunction[]; | ||
headers?: Headers[]; | ||
method?: string; | ||
@@ -34,2 +35,5 @@ authToken?: string; | ||
}; | ||
parametersBeforeFiles?: boolean; | ||
formatDataFunction?: Function; | ||
formatDataFunctionIsAsync?: boolean; | ||
} | ||
@@ -39,3 +43,3 @@ export declare class FileUploader { | ||
isUploading: boolean; | ||
queue: Array<FileItem>; | ||
queue: FileItem[]; | ||
progress: number; | ||
@@ -45,2 +49,3 @@ _nextIndex: number; | ||
authTokenHeader: string; | ||
response: EventEmitter<any>; | ||
options: FileUploaderOptions; | ||
@@ -60,4 +65,4 @@ protected _failFilterIndex: number; | ||
getIndexOfItem(value: any): number; | ||
getNotUploadedItems(): Array<any>; | ||
getReadyItems(): Array<any>; | ||
getNotUploadedItems(): any[]; | ||
getReadyItems(): any[]; | ||
destroy(): void; | ||
@@ -64,0 +69,0 @@ onAfterAddingAll(fileItems: any): any; |
"use strict"; | ||
var core_1 = require("@angular/core"); | ||
var file_like_object_class_1 = require("./file-like-object.class"); | ||
@@ -19,11 +20,14 @@ var file_item_class_1 = require("./file-item.class"); | ||
removeAfterUpload: false, | ||
disableMultipart: false | ||
disableMultipart: false, | ||
formatDataFunction: function (item) { return item._file; }, | ||
formatDataFunctionIsAsync: false | ||
}; | ||
this.setOptions(options); | ||
this.response = new core_1.EventEmitter(); | ||
} | ||
FileUploader.prototype.setOptions = function (options) { | ||
this.options = Object.assign(this.options, options); | ||
this.authToken = options.authToken; | ||
this.authTokenHeader = options.authTokenHeader || 'Authorization'; | ||
this.autoUpload = options.autoUpload; | ||
this.authToken = this.options.authToken; | ||
this.authTokenHeader = this.options.authTokenHeader || 'Authorization'; | ||
this.autoUpload = this.options.autoUpload; | ||
this.options.filters.unshift({ name: 'queueLimit', fn: this._queueLimitFilter }); | ||
@@ -42,3 +46,2 @@ if (this.options.maxFileSize) { | ||
} | ||
// this.options.filters.unshift({name: 'folder', fn: this._folderFilter}); | ||
}; | ||
@@ -145,7 +148,2 @@ FileUploader.prototype.addToQueue = function (files, options, filters) { | ||
return void 0; | ||
/*forEach(this._directives, (key) => { | ||
forEach(this._directives[key], (object) => { | ||
object.destroy(); | ||
}); | ||
});*/ | ||
}; | ||
@@ -225,11 +223,6 @@ FileUploader.prototype.onAfterAddingAll = function (fileItems) { | ||
var _this = this; | ||
var that = this; | ||
var xhr = item._xhr = new XMLHttpRequest(); | ||
var sendable; | ||
this._onBeforeUploadItem(item); | ||
// todo | ||
/*item.formData.map(obj => { | ||
obj.map((value, key) => { | ||
form.append(key, value); | ||
}); | ||
});*/ | ||
if (typeof item._file.size !== 'number') { | ||
@@ -241,11 +234,23 @@ throw new TypeError('The file specified is no longer valid'); | ||
this._onBuildItemForm(item, sendable); | ||
sendable.append(item.alias, item._file, item.file.name); | ||
var appendFile = function () { return sendable.append(item.alias, item._file, item.file.name); }; | ||
if (!this.options.parametersBeforeFiles) { | ||
appendFile(); | ||
} | ||
// For AWS, Additional Parameters must come BEFORE Files | ||
if (this.options.additionalParameter !== undefined) { | ||
Object.keys(this.options.additionalParameter).forEach(function (key) { | ||
sendable.append(key, _this.options.additionalParameter[key]); | ||
var paramVal = _this.options.additionalParameter[key]; | ||
// Allow an additional parameter to include the filename | ||
if (typeof paramVal === 'string' && paramVal.indexOf('{{file_name}}') >= 0) { | ||
paramVal = paramVal.replace('{{file_name}}', item.file.name); | ||
} | ||
sendable.append(key, paramVal); | ||
}); | ||
} | ||
if (this.options.parametersBeforeFiles) { | ||
appendFile(); | ||
} | ||
} | ||
else { | ||
sendable = item._file; | ||
sendable = this.options.formatDataFunction(item); | ||
} | ||
@@ -293,3 +298,13 @@ xhr.upload.onprogress = function (event) { | ||
} | ||
xhr.send(sendable); | ||
xhr.onreadystatechange = function () { | ||
if (xhr.readyState == XMLHttpRequest.DONE) { | ||
that.response.emit(xhr.responseText); | ||
} | ||
}; | ||
if (this.options.formatDataFunctionIsAsync) { | ||
sendable.then(function (result) { return xhr.send(JSON.stringify(result)); }); | ||
} | ||
else { | ||
xhr.send(sendable); | ||
} | ||
this._render(); | ||
@@ -324,7 +339,3 @@ }; | ||
return void 0; | ||
// todo: ? | ||
}; | ||
// protected _folderFilter(item:FileItem):boolean { | ||
// return !!(item.size || item.type); | ||
// } | ||
FileUploader.prototype._queueLimitFilter = function () { | ||
@@ -344,12 +355,5 @@ return this.options.queueLimit === undefined || this.queue.length < this.options.queueLimit; | ||
}; | ||
/* tslint:disable */ | ||
FileUploader.prototype._transformResponse = function (response, headers) { | ||
// todo: ? | ||
/*var headersGetter = this._headersGetter(headers); | ||
forEach($http.defaults.transformResponse, (transformFn) => { | ||
response = transformFn(response, headersGetter); | ||
});*/ | ||
return response; | ||
}; | ||
/* tslint:enable */ | ||
FileUploader.prototype._parseHeaders = function (headers) { | ||
@@ -373,5 +377,2 @@ var parsed = {}; | ||
}; | ||
/*protected _iframeTransport(item:FileItem) { | ||
// todo: implement it later | ||
}*/ | ||
FileUploader.prototype._onWhenAddingFileFailed = function (item, filter, options) { | ||
@@ -402,3 +403,2 @@ this.onWhenAddingFileFailed(item, filter, options); | ||
}; | ||
/* tslint:disable */ | ||
FileUploader.prototype._onSuccessItem = function (item, response, status, headers) { | ||
@@ -408,3 +408,2 @@ item._onSuccess(response, status, headers); | ||
}; | ||
/* tslint:enable */ | ||
FileUploader.prototype._onCancelItem = function (item, response, status, headers) { | ||
@@ -411,0 +410,0 @@ item._onCancel(response, status, headers); |
@@ -1,1 +0,1 @@ | ||
[{"__symbolic":"module","version":3,"metadata":{"FileUploader":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"error","message":"Could not resolve type","line":56,"character":29,"context":{"typeName":"FileUploaderOptions"}}]}],"setOptions":[{"__symbolic":"method"}],"addToQueue":[{"__symbolic":"method"}],"removeFromQueue":[{"__symbolic":"method"}],"clearQueue":[{"__symbolic":"method"}],"uploadItem":[{"__symbolic":"method"}],"cancelItem":[{"__symbolic":"method"}],"uploadAll":[{"__symbolic":"method"}],"cancelAll":[{"__symbolic":"method"}],"isFile":[{"__symbolic":"method"}],"isFileLikeObject":[{"__symbolic":"method"}],"getIndexOfItem":[{"__symbolic":"method"}],"getNotUploadedItems":[{"__symbolic":"method"}],"getReadyItems":[{"__symbolic":"method"}],"destroy":[{"__symbolic":"method"}],"onAfterAddingAll":[{"__symbolic":"method"}],"onBuildItemForm":[{"__symbolic":"method"}],"onAfterAddingFile":[{"__symbolic":"method"}],"onWhenAddingFileFailed":[{"__symbolic":"method"}],"onBeforeUploadItem":[{"__symbolic":"method"}],"onProgressItem":[{"__symbolic":"method"}],"onProgressAll":[{"__symbolic":"method"}],"onSuccessItem":[{"__symbolic":"method"}],"onErrorItem":[{"__symbolic":"method"}],"onCancelItem":[{"__symbolic":"method"}],"onCompleteItem":[{"__symbolic":"method"}],"onCompleteAll":[{"__symbolic":"method"}],"_mimeTypeFilter":[{"__symbolic":"method"}],"_fileSizeFilter":[{"__symbolic":"method"}],"_fileTypeFilter":[{"__symbolic":"method"}],"_onErrorItem":[{"__symbolic":"method"}],"_onCompleteItem":[{"__symbolic":"method"}],"_headersGetter":[{"__symbolic":"method"}],"_xhrTransport":[{"__symbolic":"method"}],"_getTotalProgress":[{"__symbolic":"method"}],"_getFilters":[{"__symbolic":"method"}],"_render":[{"__symbolic":"method"}],"_queueLimitFilter":[{"__symbolic":"method"}],"_isValidFile":[{"__symbolic":"method"}],"_isSuccessCode":[{"__symbolic":"method"}],"_transformResponse":[{"__symbolic":"method"}],"_parseHeaders":[{"__symbolic":"method"}],"_onWhenAddingFileFailed":[{"__symbolic":"method"}],"_onAfterAddingFile":[{"__symbolic":"method"}],"_onAfterAddingAll":[{"__symbolic":"method"}],"_onBeforeUploadItem":[{"__symbolic":"method"}],"_onBuildItemForm":[{"__symbolic":"method"}],"_onProgressItem":[{"__symbolic":"method"}],"_onSuccessItem":[{"__symbolic":"method"}],"_onCancelItem":[{"__symbolic":"method"}]}}}},{"__symbolic":"module","version":1,"metadata":{"FileUploader":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"error","message":"Could not resolve type","line":56,"character":29,"context":{"typeName":"FileUploaderOptions"}}]}],"setOptions":[{"__symbolic":"method"}],"addToQueue":[{"__symbolic":"method"}],"removeFromQueue":[{"__symbolic":"method"}],"clearQueue":[{"__symbolic":"method"}],"uploadItem":[{"__symbolic":"method"}],"cancelItem":[{"__symbolic":"method"}],"uploadAll":[{"__symbolic":"method"}],"cancelAll":[{"__symbolic":"method"}],"isFile":[{"__symbolic":"method"}],"isFileLikeObject":[{"__symbolic":"method"}],"getIndexOfItem":[{"__symbolic":"method"}],"getNotUploadedItems":[{"__symbolic":"method"}],"getReadyItems":[{"__symbolic":"method"}],"destroy":[{"__symbolic":"method"}],"onAfterAddingAll":[{"__symbolic":"method"}],"onBuildItemForm":[{"__symbolic":"method"}],"onAfterAddingFile":[{"__symbolic":"method"}],"onWhenAddingFileFailed":[{"__symbolic":"method"}],"onBeforeUploadItem":[{"__symbolic":"method"}],"onProgressItem":[{"__symbolic":"method"}],"onProgressAll":[{"__symbolic":"method"}],"onSuccessItem":[{"__symbolic":"method"}],"onErrorItem":[{"__symbolic":"method"}],"onCancelItem":[{"__symbolic":"method"}],"onCompleteItem":[{"__symbolic":"method"}],"onCompleteAll":[{"__symbolic":"method"}],"_mimeTypeFilter":[{"__symbolic":"method"}],"_fileSizeFilter":[{"__symbolic":"method"}],"_fileTypeFilter":[{"__symbolic":"method"}],"_onErrorItem":[{"__symbolic":"method"}],"_onCompleteItem":[{"__symbolic":"method"}],"_headersGetter":[{"__symbolic":"method"}],"_xhrTransport":[{"__symbolic":"method"}],"_getTotalProgress":[{"__symbolic":"method"}],"_getFilters":[{"__symbolic":"method"}],"_render":[{"__symbolic":"method"}],"_queueLimitFilter":[{"__symbolic":"method"}],"_isValidFile":[{"__symbolic":"method"}],"_isSuccessCode":[{"__symbolic":"method"}],"_transformResponse":[{"__symbolic":"method"}],"_parseHeaders":[{"__symbolic":"method"}],"_onWhenAddingFileFailed":[{"__symbolic":"method"}],"_onAfterAddingFile":[{"__symbolic":"method"}],"_onAfterAddingAll":[{"__symbolic":"method"}],"_onBeforeUploadItem":[{"__symbolic":"method"}],"_onBuildItemForm":[{"__symbolic":"method"}],"_onProgressItem":[{"__symbolic":"method"}],"_onSuccessItem":[{"__symbolic":"method"}],"_onCancelItem":[{"__symbolic":"method"}]}}}}] | ||
[{"__symbolic":"module","version":3,"metadata":{"FileUploader":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"error","message":"Could not resolve type","line":66,"character":30,"context":{"typeName":"FileUploaderOptions"}}]}],"setOptions":[{"__symbolic":"method"}],"addToQueue":[{"__symbolic":"method"}],"removeFromQueue":[{"__symbolic":"method"}],"clearQueue":[{"__symbolic":"method"}],"uploadItem":[{"__symbolic":"method"}],"cancelItem":[{"__symbolic":"method"}],"uploadAll":[{"__symbolic":"method"}],"cancelAll":[{"__symbolic":"method"}],"isFile":[{"__symbolic":"method"}],"isFileLikeObject":[{"__symbolic":"method"}],"getIndexOfItem":[{"__symbolic":"method"}],"getNotUploadedItems":[{"__symbolic":"method"}],"getReadyItems":[{"__symbolic":"method"}],"destroy":[{"__symbolic":"method"}],"onAfterAddingAll":[{"__symbolic":"method"}],"onBuildItemForm":[{"__symbolic":"method"}],"onAfterAddingFile":[{"__symbolic":"method"}],"onWhenAddingFileFailed":[{"__symbolic":"method"}],"onBeforeUploadItem":[{"__symbolic":"method"}],"onProgressItem":[{"__symbolic":"method"}],"onProgressAll":[{"__symbolic":"method"}],"onSuccessItem":[{"__symbolic":"method"}],"onErrorItem":[{"__symbolic":"method"}],"onCancelItem":[{"__symbolic":"method"}],"onCompleteItem":[{"__symbolic":"method"}],"onCompleteAll":[{"__symbolic":"method"}],"_mimeTypeFilter":[{"__symbolic":"method"}],"_fileSizeFilter":[{"__symbolic":"method"}],"_fileTypeFilter":[{"__symbolic":"method"}],"_onErrorItem":[{"__symbolic":"method"}],"_onCompleteItem":[{"__symbolic":"method"}],"_headersGetter":[{"__symbolic":"method"}],"_xhrTransport":[{"__symbolic":"method"}],"_getTotalProgress":[{"__symbolic":"method"}],"_getFilters":[{"__symbolic":"method"}],"_render":[{"__symbolic":"method"}],"_queueLimitFilter":[{"__symbolic":"method"}],"_isValidFile":[{"__symbolic":"method"}],"_isSuccessCode":[{"__symbolic":"method"}],"_transformResponse":[{"__symbolic":"method"}],"_parseHeaders":[{"__symbolic":"method"}],"_onWhenAddingFileFailed":[{"__symbolic":"method"}],"_onAfterAddingFile":[{"__symbolic":"method"}],"_onAfterAddingAll":[{"__symbolic":"method"}],"_onBeforeUploadItem":[{"__symbolic":"method"}],"_onBuildItemForm":[{"__symbolic":"method"}],"_onProgressItem":[{"__symbolic":"method"}],"_onSuccessItem":[{"__symbolic":"method"}],"_onCancelItem":[{"__symbolic":"method"}]}}}},{"__symbolic":"module","version":1,"metadata":{"FileUploader":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"error","message":"Could not resolve type","line":66,"character":30,"context":{"typeName":"FileUploaderOptions"}}]}],"setOptions":[{"__symbolic":"method"}],"addToQueue":[{"__symbolic":"method"}],"removeFromQueue":[{"__symbolic":"method"}],"clearQueue":[{"__symbolic":"method"}],"uploadItem":[{"__symbolic":"method"}],"cancelItem":[{"__symbolic":"method"}],"uploadAll":[{"__symbolic":"method"}],"cancelAll":[{"__symbolic":"method"}],"isFile":[{"__symbolic":"method"}],"isFileLikeObject":[{"__symbolic":"method"}],"getIndexOfItem":[{"__symbolic":"method"}],"getNotUploadedItems":[{"__symbolic":"method"}],"getReadyItems":[{"__symbolic":"method"}],"destroy":[{"__symbolic":"method"}],"onAfterAddingAll":[{"__symbolic":"method"}],"onBuildItemForm":[{"__symbolic":"method"}],"onAfterAddingFile":[{"__symbolic":"method"}],"onWhenAddingFileFailed":[{"__symbolic":"method"}],"onBeforeUploadItem":[{"__symbolic":"method"}],"onProgressItem":[{"__symbolic":"method"}],"onProgressAll":[{"__symbolic":"method"}],"onSuccessItem":[{"__symbolic":"method"}],"onErrorItem":[{"__symbolic":"method"}],"onCancelItem":[{"__symbolic":"method"}],"onCompleteItem":[{"__symbolic":"method"}],"onCompleteAll":[{"__symbolic":"method"}],"_mimeTypeFilter":[{"__symbolic":"method"}],"_fileSizeFilter":[{"__symbolic":"method"}],"_fileTypeFilter":[{"__symbolic":"method"}],"_onErrorItem":[{"__symbolic":"method"}],"_onCompleteItem":[{"__symbolic":"method"}],"_headersGetter":[{"__symbolic":"method"}],"_xhrTransport":[{"__symbolic":"method"}],"_getTotalProgress":[{"__symbolic":"method"}],"_getFilters":[{"__symbolic":"method"}],"_render":[{"__symbolic":"method"}],"_queueLimitFilter":[{"__symbolic":"method"}],"_isValidFile":[{"__symbolic":"method"}],"_isSuccessCode":[{"__symbolic":"method"}],"_transformResponse":[{"__symbolic":"method"}],"_parseHeaders":[{"__symbolic":"method"}],"_onWhenAddingFileFailed":[{"__symbolic":"method"}],"_onAfterAddingFile":[{"__symbolic":"method"}],"_onAfterAddingAll":[{"__symbolic":"method"}],"_onBeforeUploadItem":[{"__symbolic":"method"}],"_onBuildItemForm":[{"__symbolic":"method"}],"_onProgressItem":[{"__symbolic":"method"}],"_onSuccessItem":[{"__symbolic":"method"}],"_onCancelItem":[{"__symbolic":"method"}]}}}}] |
{ | ||
"main": "bundles/ng2-file-upload.umd.js", | ||
"version": "1.2.1", | ||
"version": "1.3.0", | ||
"description": "Angular file upload directives", | ||
@@ -29,5 +29,5 @@ "module": "index.js", | ||
}, | ||
"_id": "ng2-file-upload@1.2.1", | ||
"_id": "ng2-file-upload@1.3.0", | ||
"devDependencies": {}, | ||
"dependencies": {} | ||
} |
@@ -28,2 +28,5 @@ # ng2-file-upload [![npm version](https://badge.fury.io/js/ng2-file-upload.svg)](http://badge.fury.io/js/ng2-file-upload) [![npm downloads](https://img.shields.io/npm/dm/ng2-file-upload.svg)](https://npmjs.org/ng2-file-upload)[![slack](https://ngx-slack.herokuapp.com/badge.svg)](https://ngx-slack.herokuapp.com) | ||
### Events | ||
- `onFileSelected` - fires when files are selected and added to the uploader queue | ||
## API for `ng2FileDrop` | ||
@@ -41,2 +44,5 @@ | ||
4. `itemAlias` - item alias (form name redefenition) | ||
5. `formatDataFunction` - Function to modify the request body. 'DisableMultipart' must be 'true' for this function to be called. | ||
6. `formatDataFunctionIsAsync` - Informs if the function sent in 'formatDataFunction' is asynchronous. Defaults to false. | ||
7. `parametersBeforeFiles` - States if additional parameters should be appended before or after the file. Defaults to false. | ||
@@ -48,2 +54,3 @@ ### Events | ||
[html demo](https://github.com/valor-software/ng2-file-upload/blob/master/demo/components/file-upload/simple-demo.html) | ||
- `onFileDrop` - it fires after a file has been dropped on a Drop Area; you can pass in `$event` to get the list of files that were dropped. i.e. `(onFileDrop)="dropped($event)"` | ||
@@ -50,0 +57,0 @@ # Troubleshooting |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
186674
2170
66
94846
1