Skip to content

Commit

Permalink
handle maxUploads option bleenco#96 (bleenco#218)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasz-galka authored and jkuri committed Feb 23, 2017
1 parent 347c9b2 commit b074f80
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/classes/upload-rejected.class.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export class UploadRejected {
public static get EXTENSION_NOT_ALLOWED(): string { return 'ExtensionNotAllowed'; }
public static get MAX_SIZE_EXCEEDED(): string { return 'MaxSizeExceeded'; }
public static get MAX_UPLOADS_EXCEEDED(): string { return 'MaxUploadsExceeded'; }

file: any;
reason: string;
Expand Down
5 changes: 5 additions & 0 deletions src/directives/ng-file-select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ export class NgFileSelectDirective implements OnChanges {
});
}

if(this.options.maxUploads > 0 && this.files.length > this.options.maxUploads) {
this.onUploadRejected.emit({file: this.files.pop(), reason: UploadRejected.MAX_UPLOADS_EXCEEDED});
this.files = [];
}

if (this.files && this.files.length) {
this.uploader.addFilesToQueue(this.files);
}
Expand Down

0 comments on commit b074f80

Please sign in to comment.