Handled error on upload file

This commit is contained in:
Giuseppe
2018-10-09 11:56:14 +02:00
parent e7dc095156
commit a33513ef4b
3 changed files with 15 additions and 1 deletions

View File

@@ -58,6 +58,11 @@ export class UploaderComponent {
*/
@Output() onCompleteItem: EventEmitter<any> = new EventEmitter<any>();
/**
* The function to call on error occurred
*/
@Output() onUploadError: EventEmitter<any> = new EventEmitter<any>();
public uploader: FileUploader;
public uploaderId: string;
public isOverBaseDropZone = Observable.of(false);
@@ -125,6 +130,10 @@ export class UploaderComponent {
this.onCompleteItem.emit(responsePath);
}
};
this.uploader.onErrorItem = (item: any, response: any, status: any, headers: any) => {
this.onUploadError.emit(null);
this.uploader.cancelAll();
};
this.uploader.onProgressAll = () => this.onProgress();
this.uploader.onProgressItem = () => this.onProgress();
}