diff --git a/src/components/app-home/app-home.component.ts b/src/components/app-home/app-home.component.ts index 0a290c09..dac5330d 100644 --- a/src/components/app-home/app-home.component.ts +++ b/src/components/app-home/app-home.component.ts @@ -24,8 +24,8 @@ export class AppHomeComponent { if (output.type === 'allAddedToQueue') { const event: UploadInput = { type: 'uploadAll', - url: 'http://ngx-uploader.com/upload', - method: 'POST', + url: 'http://ngx-uploader.com/upload', + method: 'POST', data: { foo: 'bar' } }; diff --git a/src/ngx-uploader/classes/ngx-uploader.class.ts b/src/ngx-uploader/classes/ngx-uploader.class.ts index ab19d8ff..3a7736f5 100644 --- a/src/ngx-uploader/classes/ngx-uploader.class.ts +++ b/src/ngx-uploader/classes/ngx-uploader.class.ts @@ -40,13 +40,13 @@ export class NgUploaderService { let allowedIncomingFiles: File[] = []; for (let i = 0; i < incomingFiles.length; i++) { - let checkFile = incomingFiles[i]; - if (this.isContentTypeAllowed(checkFile.type)) { - allowedIncomingFiles.push(checkFile); - } else { - const rejectedFile: UploadFile = this.makeUploadFile(checkFile, i); - this.serviceEvents.emit({ type: 'rejected', file: rejectedFile }); - } + let checkFile = incomingFiles[i]; + if (this.isContentTypeAllowed(checkFile.type)) { + allowedIncomingFiles.push(checkFile); + } else { + const rejectedFile: UploadFile = this.makeUploadFile(checkFile, i); + this.serviceEvents.emit({ type: 'rejected', file: rejectedFile }); + } } this.queue.push(...[].map.call(allowedIncomingFiles, (file: File, i: number) => { @@ -262,33 +262,32 @@ export class NgUploaderService { if (this.contentTypes.find((type: string) => type === mimetype ) !== undefined) { return true; } - return false; } private makeUploadFile(file: File, index: number): UploadFile { return { - fileIndex: index, - id: this.generateId(), - name: file.name, - size: file.size, - type: file.type, - form: new FormData(), - progress: { - status: UploadStatus.Queue, - data: { - percentage: 0, - speed: 0, - speedHuman: `${humanizeBytes(0)}/s`, - startTime: null, - endTime: null, - eta: null, - etaHuman: null - } - }, - lastModifiedDate: file.lastModifiedDate, - sub: undefined, - nativeFile: file + fileIndex: index, + id: this.generateId(), + name: file.name, + size: file.size, + type: file.type, + form: new FormData(), + progress: { + status: UploadStatus.Queue, + data: { + percentage: 0, + speed: 0, + speedHuman: `${humanizeBytes(0)}/s`, + startTime: null, + endTime: null, + eta: null, + etaHuman: null + } + }, + lastModifiedDate: file.lastModifiedDate, + sub: undefined, + nativeFile: file }; } }