diff --git a/bundles/ngx-uploader.umd.js b/bundles/ngx-uploader.umd.js index f90d60bf..f5212e9f 100644 --- a/bundles/ngx-uploader.umd.js +++ b/bundles/ngx-uploader.umd.js @@ -1,2 +1,2 @@ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@angular/core"),require("@angular/common"),require("rxjs/Observable"),require("rxjs/Subscriber"),require("rxjs/add/observable/from"),require("rxjs/add/observable/merge"),require("rxjs/add/operator/combineLatest"),require("rxjs/add/operator/mergeAll")):"function"==typeof define&&define.amd?define("ngx-uploader",["@angular/core","@angular/common","rxjs/Observable","rxjs/Subscriber","rxjs/add/observable/from","rxjs/add/observable/merge","rxjs/add/operator/combineLatest","rxjs/add/operator/mergeAll"],t):"object"==typeof exports?exports["ngx-uploader"]=t(require("@angular/core"),require("@angular/common"),require("rxjs/Observable"),require("rxjs/Subscriber"),require("rxjs/add/observable/from"),require("rxjs/add/observable/merge"),require("rxjs/add/operator/combineLatest"),require("rxjs/add/operator/mergeAll")):e["ngx-uploader"]=t(e["@angular/core"],e["@angular/common"],e["rxjs/Observable"],e["rxjs/Subscriber"],e["rxjs/add/observable/from"],e["rxjs/add/observable/merge"],e["rxjs/add/operator/combineLatest"],e["rxjs/add/operator/mergeAll"])}(this,function(e,t,r,n,i,o,s,a){return function(e){function t(n){if(r[n])return r[n].exports;var i=r[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var r={};return t.m=e,t.c=r,t.i=function(e){return e},t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="/",t(t.s=6)}([function(t,r){t.exports=e},function(e,t,r){"use strict";function n(e){if(0===e)return"0 Byte";var t=["Bytes","KB","MB","GB","TB","PB"],r=Math.floor(Math.log(e)/Math.log(1024));return parseFloat((e/Math.pow(1024,r)).toFixed(2))+" "+t[r]}var i=r(0),o=(r.n(i),r(7)),s=(r.n(o),r(8)),a=(r.n(s),r(10)),u=(r.n(a),r(9)),p=(r.n(u),r(12)),l=(r.n(p),r(11));r.n(l);r.d(t,"a",function(){return c}),t.b=n,r.d(t,"c",function(){return d});var c;!function(e){e[e.Queue=0]="Queue",e[e.Uploading=1]="Uploading",e[e.Done=2]="Done",e[e.Canceled=3]="Canceled"}(c||(c={}));var d=function(){function e(){this.files=[],this.serviceEvents=new i.EventEmitter,this.uploads=[]}return e.prototype.handleFiles=function(e){var t=this;this.fileList=e,this.files=[].map.call(e,function(e,r){var n={fileIndex:r,id:t.generateId(),name:e.name,size:e.size,type:e.type,progress:{status:c.Queue,data:{percentage:0,speed:null,speedHuman:null}},lastModifiedDate:e.lastModifiedDate};return t.serviceEvents.emit({type:"addedToQueue",file:n}),n}),this.serviceEvents.emit({type:"allAddedToQueue"})},e.prototype.initInputEvents=function(e){var t=this;e.subscribe(function(e){switch(e.type){case"uploadFile":t.serviceEvents.emit({type:"start",file:e.file});var r=t.uploadFile(e.file,e).subscribe(function(e){t.serviceEvents.emit(e)});t.uploads.push({file:e.file,sub:r});break;case"uploadAll":var n=e.concurrency>0?e.concurrency:Number.POSITIVE_INFINITY,i=s.Subscriber.create(function(e){t.serviceEvents.emit(e)});t.uploads=t.uploads.concat(t.files.map(function(e){return{file:e,sub:null}}));o.Observable.from(t.files.map(function(r){return t.uploadFile(r,e)})).mergeAll(n).combineLatest(function(e){return e}).subscribe(i);break;case"cancel":var a=e.id||null;if(!a)return;var u=t.uploads.findIndex(function(e){return e.file.id===a});-1!==u&&(t.uploads[u].sub&&t.uploads[u].sub.unsubscribe(),t.serviceEvents.emit({type:"cancelled",file:t.uploads[u].file}),t.uploads[u].file.progress.status=c.Canceled);break;case"cancelAll":t.uploads.forEach(function(e){e.file.progress.status=c.Canceled,t.serviceEvents.emit({type:"cancelled",file:e.file})})}})},e.prototype.uploadFile=function(e,t){var r=this;return new o.Observable(function(i){var o=t.url,s=t.method||"POST",a=t.data||{},u=t.headers||{},p=new FileReader,l=new XMLHttpRequest,d=(new Date).getTime(),f=0;l.upload.addEventListener("progress",function(t){if(t.lengthComputable){var r=Math.round(100*t.loaded/t.total),o=(new Date).getTime()-d;d+=o,f=t.loaded-f;var s=parseInt(f/o*1e3,10);e.progress={status:c.Uploading,data:{percentage:r,speed:s,speedHuman:n(s)+"/s"}},i.next({type:"uploading",file:e})}},!1),l.upload.addEventListener("error",function(e){i.error(e),i.complete()}),l.onreadystatechange=function(){if(l.readyState===XMLHttpRequest.DONE){e.progress={status:c.Done,data:{percentage:100,speed:null,speedHuman:null}};try{e.response=JSON.parse(l.response)}catch(t){e.response=l.response}i.next({type:"done",file:e}),i.complete()}},l.open(s,o,!0);var v=new FormData;try{var h=r.fileList.item(e.fileIndex),m=r.uploads.findIndex(function(e){return e.file.size===h.size});r.uploads[m].file.progress.status===c.Canceled&&i.complete(),v.append("file",h,h.name),Object.keys(a).forEach(function(e){return v.append(e,a[e])}),Object.keys(u).forEach(function(e){return l.setRequestHeader(e,u[e])}),r.serviceEvents.emit({type:"start",file:e}),l.send(v)}catch(e){i.complete()}return function(){l.abort(),p.abort()}})},e.prototype.generateId=function(){return Math.random().toString(36).substring(7)},e}()},function(e,t,r){"use strict";var n=r(0),i=(r.n(n),r(4)),o=(r.n(i),r(1));r.d(t,"a",function(){return p});var s=this&&this.__decorate||function(e,t,r,n){var i,o=arguments.length,s=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,r,s):i(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},a=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},u=this&&this.__param||function(e,t){return function(r,n){t(r,n,e)}},p=function(){function e(e,t){this.platform_id=e,this.elementRef=t,this.isServer=r.i(i.isPlatformServer)(this.platform_id),this.stopEvent=function(e){e.stopPropagation(),e.preventDefault()},this.upload=new o.c,this.uploadOutput=new n.EventEmitter}return e.prototype.ngOnInit=function(){var e=this;this.isServer||(this.el=this.elementRef.nativeElement,this.upload.serviceEvents.subscribe(function(t){e.uploadOutput.emit(t)}),this.uploadInput instanceof n.EventEmitter&&this.upload.initInputEvents(this.uploadInput),this.el.addEventListener("drop",this.stopEvent,!1),this.el.addEventListener("dragenter",this.stopEvent,!1),this.el.addEventListener("dragover",this.stopEvent,!1),this.el.addEventListener("dragover",this.stopEvent,!1))},e.prototype.ngOnDestroy=function(){this.isServer||this.uploadInput.unsubscribe()},e.prototype.onDrop=function(e){e.stopPropagation(),e.preventDefault();var t={type:"drop"};this.uploadOutput.emit(t),this.upload.handleFiles(e.dataTransfer.files)},e.prototype.onDragOver=function(e){if(e){var t={type:"dragOver"};this.uploadOutput.emit(t)}},e.prototype.onDragLeave=function(e){if(e){var t={type:"dragOut"};this.uploadOutput.emit(t)}},e}();s([r.i(n.Input)(),a("design:type",n.EventEmitter)],p.prototype,"uploadInput",void 0),s([r.i(n.Output)(),a("design:type",n.EventEmitter)],p.prototype,"uploadOutput",void 0),s([r.i(n.HostListener)("drop",["$event"]),a("design:type",Function),a("design:paramtypes",[Object]),a("design:returntype",void 0)],p.prototype,"onDrop",null),s([r.i(n.HostListener)("dragover",["$event"]),a("design:type",Function),a("design:paramtypes",[Event]),a("design:returntype",void 0)],p.prototype,"onDragOver",null),s([r.i(n.HostListener)("dragleave",["$event"]),a("design:type",Function),a("design:paramtypes",[Event]),a("design:returntype",void 0)],p.prototype,"onDragLeave",null),p=s([r.i(n.Directive)({selector:"[ngFileDrop]"}),u(0,r.i(n.Inject)(n.PLATFORM_ID)),a("design:paramtypes",[Object,n.ElementRef])],p)},function(e,t,r){"use strict";var n=r(0),i=(r.n(n),r(4)),o=(r.n(i),r(1));r.d(t,"a",function(){return p});var s=this&&this.__decorate||function(e,t,r,n){var i,o=arguments.length,s=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,r,s):i(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},a=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},u=this&&this.__param||function(e,t){return function(r,n){t(r,n,e)}},p=function(){function e(e,t){var s=this;this.platform_id=e,this.elementRef=t,this.isServer=r.i(i.isPlatformServer)(this.platform_id),this.fileListener=function(){s.upload.handleFiles(s.el.files)},this.upload=new o.c,this.uploadOutput=new n.EventEmitter}return e.prototype.ngOnInit=function(){var e=this;this.isServer||(this.el=this.elementRef.nativeElement,this.el.addEventListener("change",this.fileListener,!1),this.upload.serviceEvents.subscribe(function(t){e.uploadOutput.emit(t)}),this.uploadInput instanceof n.EventEmitter&&this.upload.initInputEvents(this.uploadInput))},e.prototype.ngOnDestroy=function(){this.isServer||(this.el.removeEventListener("change",this.fileListener,!1),this.uploadInput.unsubscribe())},e}();s([r.i(n.Input)(),a("design:type",n.EventEmitter)],p.prototype,"uploadInput",void 0),s([r.i(n.Output)(),a("design:type",n.EventEmitter)],p.prototype,"uploadOutput",void 0),p=s([r.i(n.Directive)({selector:"[ngFileSelect]"}),u(0,r.i(n.Inject)(n.PLATFORM_ID)),a("design:paramtypes",[Object,n.ElementRef])],p)},function(e,r){e.exports=t},function(e,t,r){"use strict";var n=r(0),i=(r.n(n),r(2)),o=r(3);r.d(t,"a",function(){return a});var s=this&&this.__decorate||function(e,t,r,n){var i,o=arguments.length,s=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,r,s):i(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},a=function(){function e(){}return e}();a=s([r.i(n.NgModule)({declarations:[o.a,i.a],exports:[o.a,i.a]})],a)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(5);r.d(t,"NgUploaderModule",function(){return n.a});var i=r(1);r.d(t,"UploadStatus",function(){return i.a}),r.d(t,"humanizeBytes",function(){return i.b}),r.d(t,"NgUploaderService",function(){return i.c});var o=r(3);r.d(t,"NgFileSelectDirective",function(){return o.a});var s=r(2);r.d(t,"NgFileDropDirective",function(){return s.a})},function(e,t){e.exports=r},function(e,t){e.exports=n},function(e,t){e.exports=i},function(e,t){e.exports=o},function(e,t){e.exports=s},function(e,t){e.exports=a}])}); +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@angular/core"),require("@angular/common"),require("rxjs/Observable"),require("rxjs/Subscriber"),require("rxjs/add/observable/from"),require("rxjs/add/observable/merge"),require("rxjs/add/operator/combineLatest"),require("rxjs/add/operator/mergeAll")):"function"==typeof define&&define.amd?define("ngx-uploader",["@angular/core","@angular/common","rxjs/Observable","rxjs/Subscriber","rxjs/add/observable/from","rxjs/add/observable/merge","rxjs/add/operator/combineLatest","rxjs/add/operator/mergeAll"],t):"object"==typeof exports?exports["ngx-uploader"]=t(require("@angular/core"),require("@angular/common"),require("rxjs/Observable"),require("rxjs/Subscriber"),require("rxjs/add/observable/from"),require("rxjs/add/observable/merge"),require("rxjs/add/operator/combineLatest"),require("rxjs/add/operator/mergeAll")):e["ngx-uploader"]=t(e["@angular/core"],e["@angular/common"],e["rxjs/Observable"],e["rxjs/Subscriber"],e["rxjs/add/observable/from"],e["rxjs/add/observable/merge"],e["rxjs/add/operator/combineLatest"],e["rxjs/add/operator/mergeAll"])}(this,function(e,t,r,n,i,o,s,a){return function(e){function t(n){if(r[n])return r[n].exports;var i=r[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var r={};return t.m=e,t.c=r,t.i=function(e){return e},t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="/",t(t.s=6)}([function(t,r){t.exports=e},function(e,t,r){"use strict";function n(e){if(0===e)return"0 Byte";var t=["Bytes","KB","MB","GB","TB","PB"],r=Math.floor(Math.log(e)/Math.log(1024));return parseFloat((e/Math.pow(1024,r)).toFixed(2))+" "+t[r]}r.d(t,"a",function(){return i}),t.b=n,r.d(t,"c",function(){return d});var i,o=r(0),s=(r.n(o),r(7)),a=(r.n(s),r(8)),u=(r.n(a),r(10)),p=(r.n(u),r(9)),l=(r.n(p),r(12)),c=(r.n(l),r(11));r.n(c);!function(e){e[e.Queue=0]="Queue",e[e.Uploading=1]="Uploading",e[e.Done=2]="Done",e[e.Canceled=3]="Canceled"}(i||(i={}));var d=function(){function e(){this.files=[],this.serviceEvents=new o.EventEmitter,this.uploads=[]}return e.prototype.handleFiles=function(e){var t=this;this.fileList=e,this.files=[].map.call(e,function(e,r){var n={fileIndex:r,id:t.generateId(),name:e.name,size:e.size,type:e.type,progress:{status:i.Queue,data:{percentage:0,speed:null,speedHuman:null}},lastModifiedDate:e.lastModifiedDate};return t.serviceEvents.emit({type:"addedToQueue",file:n}),n}),this.serviceEvents.emit({type:"allAddedToQueue"})},e.prototype.initInputEvents=function(e){var t=this;e.subscribe(function(e){switch(e.type){case"uploadFile":t.serviceEvents.emit({type:"start",file:e.file});var r=t.uploadFile(e.file,e).subscribe(function(e){t.serviceEvents.emit(e)});t.uploads.push({file:e.file,sub:r});break;case"uploadAll":var n=e.concurrency>0?e.concurrency:Number.POSITIVE_INFINITY,o=a.Subscriber.create(function(e){t.serviceEvents.emit(e)});t.uploads=t.uploads.concat(t.files.map(function(e){return{file:e,sub:null}}));s.Observable.from(t.files.map(function(r){return t.uploadFile(r,e)})).mergeAll(n).combineLatest(function(e){return e}).subscribe(o);break;case"cancel":var u=e.id||null;if(!u)return;var p=t.uploads.findIndex(function(e){return e.file.id===u});-1!==p&&(t.uploads[p].sub&&t.uploads[p].sub.unsubscribe(),t.serviceEvents.emit({type:"cancelled",file:t.uploads[p].file}),t.uploads[p].file.progress.status=i.Canceled);break;case"cancelAll":t.uploads.forEach(function(e){e.file.progress.status=i.Canceled,t.serviceEvents.emit({type:"cancelled",file:e.file})})}})},e.prototype.uploadFile=function(e,t){var r=this;return new s.Observable(function(o){var s=t.url,a=t.method||"POST",u=t.data||{},p=t.headers||{},l=new FileReader,c=new XMLHttpRequest,d=(new Date).getTime(),f=0;c.upload.addEventListener("progress",function(t){if(t.lengthComputable){var r=Math.round(100*t.loaded/t.total),s=(new Date).getTime()-d;d+=s,f=t.loaded-f;var a=parseInt(f/s*1e3,10);e.progress={status:i.Uploading,data:{percentage:r,speed:a,speedHuman:n(a)+"/s"}},o.next({type:"uploading",file:e})}},!1),c.upload.addEventListener("error",function(e){o.error(e),o.complete()}),c.onreadystatechange=function(){if(c.readyState===XMLHttpRequest.DONE){e.progress={status:i.Done,data:{percentage:100,speed:null,speedHuman:null}};try{e.response=JSON.parse(c.response)}catch(t){e.response=c.response}o.next({type:"done",file:e}),o.complete()}},c.open(a,s,!0);var v=new FormData;try{var h=r.fileList.item(e.fileIndex),m=r.uploads.findIndex(function(e){return e.file.size===h.size});r.uploads[m].file.progress.status===i.Canceled&&o.complete(),v.append("file",h,h.name),Object.keys(u).forEach(function(e){return v.append(e,u[e])}),Object.keys(p).forEach(function(e){return c.setRequestHeader(e,p[e])}),r.serviceEvents.emit({type:"start",file:e}),c.send(v)}catch(e){o.complete()}return function(){c.abort(),l.abort()}})},e.prototype.generateId=function(){return Math.random().toString(36).substring(7)},e}()},function(e,t,r){"use strict";r.d(t,"a",function(){return p});var n=r(0),i=(r.n(n),r(4)),o=(r.n(i),r(1)),s=this&&this.__decorate||function(e,t,r,n){var i,o=arguments.length,s=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,r,s):i(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},a=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},u=this&&this.__param||function(e,t){return function(r,n){t(r,n,e)}},p=function(){function e(e,t){this.platform_id=e,this.elementRef=t,this.isServer=r.i(i.isPlatformServer)(this.platform_id),this.stopEvent=function(e){e.stopPropagation(),e.preventDefault()},this.upload=new o.c,this.uploadOutput=new n.EventEmitter}return e.prototype.ngOnInit=function(){var e=this;this.isServer||(this.el=this.elementRef.nativeElement,this.upload.serviceEvents.subscribe(function(t){e.uploadOutput.emit(t)}),this.uploadInput instanceof n.EventEmitter&&this.upload.initInputEvents(this.uploadInput),this.el.addEventListener("drop",this.stopEvent,!1),this.el.addEventListener("dragenter",this.stopEvent,!1),this.el.addEventListener("dragover",this.stopEvent,!1),this.el.addEventListener("dragover",this.stopEvent,!1))},e.prototype.ngOnDestroy=function(){this.isServer||this.uploadInput.unsubscribe()},e.prototype.onDrop=function(e){e.stopPropagation(),e.preventDefault();var t={type:"drop"};this.uploadOutput.emit(t),this.upload.handleFiles(e.dataTransfer.files)},e.prototype.onDragOver=function(e){if(e){var t={type:"dragOver"};this.uploadOutput.emit(t)}},e.prototype.onDragLeave=function(e){if(e){var t={type:"dragOut"};this.uploadOutput.emit(t)}},e}();s([r.i(n.Input)(),a("design:type",n.EventEmitter)],p.prototype,"uploadInput",void 0),s([r.i(n.Output)(),a("design:type",n.EventEmitter)],p.prototype,"uploadOutput",void 0),s([r.i(n.HostListener)("drop",["$event"]),a("design:type",Function),a("design:paramtypes",[Object]),a("design:returntype",void 0)],p.prototype,"onDrop",null),s([r.i(n.HostListener)("dragover",["$event"]),a("design:type",Function),a("design:paramtypes",[Event]),a("design:returntype",void 0)],p.prototype,"onDragOver",null),s([r.i(n.HostListener)("dragleave",["$event"]),a("design:type",Function),a("design:paramtypes",[Event]),a("design:returntype",void 0)],p.prototype,"onDragLeave",null),p=s([r.i(n.Directive)({selector:"[ngFileDrop]"}),u(0,r.i(n.Inject)(n.PLATFORM_ID)),a("design:paramtypes",[Object,n.ElementRef])],p)},function(e,t,r){"use strict";r.d(t,"a",function(){return p});var n=r(0),i=(r.n(n),r(4)),o=(r.n(i),r(1)),s=this&&this.__decorate||function(e,t,r,n){var i,o=arguments.length,s=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,r,s):i(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},a=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},u=this&&this.__param||function(e,t){return function(r,n){t(r,n,e)}},p=function(){function e(e,t){var s=this;this.platform_id=e,this.elementRef=t,this.isServer=r.i(i.isPlatformServer)(this.platform_id),this.fileListener=function(){s.upload.handleFiles(s.el.files)},this.upload=new o.c,this.uploadOutput=new n.EventEmitter}return e.prototype.ngOnInit=function(){var e=this;this.isServer||(this.el=this.elementRef.nativeElement,this.el.addEventListener("change",this.fileListener,!1),this.upload.serviceEvents.subscribe(function(t){e.uploadOutput.emit(t)}),this.uploadInput instanceof n.EventEmitter&&this.upload.initInputEvents(this.uploadInput))},e.prototype.ngOnDestroy=function(){this.isServer||(this.el.removeEventListener("change",this.fileListener,!1),this.uploadInput.unsubscribe())},e}();s([r.i(n.Input)(),a("design:type",n.EventEmitter)],p.prototype,"uploadInput",void 0),s([r.i(n.Output)(),a("design:type",n.EventEmitter)],p.prototype,"uploadOutput",void 0),p=s([r.i(n.Directive)({selector:"[ngFileSelect]"}),u(0,r.i(n.Inject)(n.PLATFORM_ID)),a("design:paramtypes",[Object,n.ElementRef])],p)},function(e,r){e.exports=t},function(e,t,r){"use strict";r.d(t,"a",function(){return a});var n=r(0),i=(r.n(n),r(2)),o=r(3),s=this&&this.__decorate||function(e,t,r,n){var i,o=arguments.length,s=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,r,s):i(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},a=function(){function e(){}return e}();a=s([r.i(n.NgModule)({declarations:[o.a,i.a],exports:[o.a,i.a]})],a)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(5);r.d(t,"NgUploaderModule",function(){return n.a});var i=r(1);r.d(t,"UploadStatus",function(){return i.a}),r.d(t,"humanizeBytes",function(){return i.b}),r.d(t,"NgUploaderService",function(){return i.c});var o=r(3);r.d(t,"NgFileSelectDirective",function(){return o.a});var s=r(2);r.d(t,"NgFileDropDirective",function(){return s.a})},function(e,t){e.exports=r},function(e,t){e.exports=n},function(e,t){e.exports=i},function(e,t){e.exports=o},function(e,t){e.exports=s},function(e,t){e.exports=a}])}); //# sourceMappingURL=ngx-uploader.umd.js.map \ No newline at end of file diff --git a/src/ngx-uploader/classes/ngx-uploader.class.ts b/src/ngx-uploader/classes/ngx-uploader.class.ts index 32cc335c..46189e47 100644 --- a/src/ngx-uploader/classes/ngx-uploader.class.ts +++ b/src/ngx-uploader/classes/ngx-uploader.class.ts @@ -44,6 +44,7 @@ export interface UploadInput { url?: string; method?: string; id?: string; + fieldName?: string; fileIndex?: number; file?: UploadFile; data?: { [key: string]: string | Blob }; @@ -226,7 +227,7 @@ export class NgUploaderService { observer.complete(); } - form.append('file', uploadFile, uploadFile.name); + form.append(event.fieldName || 'file', uploadFile, uploadFile.name); Object.keys(data).forEach(key => form.append(key, data[key])); Object.keys(headers).forEach(key => xhr.setRequestHeader(key, headers[key]));