diff --git a/src/directives/ng-file-drop.ts b/src/directives/ng-file-drop.ts index 3e9780fd..887a2f13 100644 --- a/src/directives/ng-file-drop.ts +++ b/src/directives/ng-file-drop.ts @@ -6,7 +6,7 @@ import { Output, HostListener } from '@angular/core'; -import {Ng2Uploader} from '../services/ng2-uploader'; +import { Ng2Uploader, UploadRejected } from '../services/ng2-uploader'; @Directive({ selector: '[ngFileDrop]' @@ -17,6 +17,7 @@ export class NgFileDropDirective { @Output() onUpload: EventEmitter = new EventEmitter(); @Output() onPreviewData: EventEmitter = new EventEmitter(); @Output() onFileOver:EventEmitter = new EventEmitter(); + @Output() onUploadRejected: EventEmitter = new EventEmitter(); _options:any; @@ -96,6 +97,8 @@ export class NgFileDropDirective { return true; } + this.onUploadRejected.emit({file: f, reason: UploadRejected.EXTENSION_NOT_ALLOWED}); + return false; }); } diff --git a/src/directives/ng-file-select.ts b/src/directives/ng-file-select.ts index e0505737..5fe1b2b1 100644 --- a/src/directives/ng-file-select.ts +++ b/src/directives/ng-file-select.ts @@ -6,7 +6,7 @@ import { Output, HostListener } from '@angular/core'; -import { Ng2Uploader } from '../services/ng2-uploader'; +import { Ng2Uploader, UploadRejected } from '../services/ng2-uploader'; @Directive({ selector: '[ngFileSelect]' @@ -16,6 +16,7 @@ export class NgFileSelectDirective { @Input() events: EventEmitter; @Output() onUpload: EventEmitter = new EventEmitter(); @Output() onPreviewData: EventEmitter = new EventEmitter(); + @Output() onUploadRejected: EventEmitter = new EventEmitter(); _options:any; @@ -74,6 +75,8 @@ export class NgFileSelectDirective { return true; } + this.onUploadRejected.emit({file: f, reason: UploadRejected.EXTENSION_NOT_ALLOWED}); + return false; }); } diff --git a/src/services/ng2-uploader.ts b/src/services/ng2-uploader.ts index 34b60067..ba00a0f0 100644 --- a/src/services/ng2-uploader.ts +++ b/src/services/ng2-uploader.ts @@ -256,6 +256,14 @@ export class Ng2Uploader { } } +export class UploadRejected { + public static get EXTENSION_NOT_ALLOWED():string { return 'ExtensionNotAllowed'; } + public static get MAX_SIZE_EXCEEDED():string { return 'MaxSizeExceeded'; } + + file: any; + reason: string; +} + function humanizeBytes(bytes: number): string { if (bytes === 0) { return '0 Byte';