diff --git a/src/platform/core/file/services/file.service.ts b/src/platform/core/file/services/file.service.ts index 8e98d0a75a..9c4eb966c7 100644 --- a/src/platform/core/file/services/file.service.ts +++ b/src/platform/core/file/services/file.service.ts @@ -44,7 +44,7 @@ export class TdFileService { */ upload(options: IUploadOptions): Observable { return new Observable((subscriber: Subscriber) => { - let xhr: XMLHttpRequest = new XMLHttpRequest(); + let xhr: XMLHttpRequest = new XMLHttpRequest(); let formData: FormData = new FormData(); if (options.file !== undefined) { @@ -53,7 +53,7 @@ export class TdFileService { formData = options.formData; } else { return subscriber.error('For [IUploadOptions] you have to set either the [file] or the [formData] property.'); - } + } xhr.upload.onprogress = (event: ProgressEvent) => { let progress: number = 0; @@ -65,8 +65,8 @@ export class TdFileService { xhr.onreadystatechange = () => { if (xhr.readyState === 4) { - if (xhr.status === 200 || xhr.status === 201) { - subscriber.next(JSON.parse(xhr.response)); + if (xhr.status >= 200 && xhr.status < 300) { + subscriber.next(xhr.response); subscriber.complete(); } else { subscriber.error(xhr.response);