From 9180f9964c90416dca342111eaea8f1804f3f182 Mon Sep 17 00:00:00 2001 From: Raph Date: Mon, 3 Jul 2017 23:18:20 +0200 Subject: [PATCH] fix(file-service): make progress based on upload API (#728) Make progress upload based on upload, not need backend compatible --- src/platform/core/file/services/file.service.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/platform/core/file/services/file.service.ts b/src/platform/core/file/services/file.service.ts index 3f0d696d54..8e98d0a75a 100644 --- a/src/platform/core/file/services/file.service.ts +++ b/src/platform/core/file/services/file.service.ts @@ -55,9 +55,9 @@ export class TdFileService { return subscriber.error('For [IUploadOptions] you have to set either the [file] or the [formData] property.'); } - xhr.onprogress = (event: ProgressEvent) => { + xhr.upload.onprogress = (event: ProgressEvent) => { let progress: number = 0; - if (event.total > 0) { + if (event.lengthComputable) { progress = Math.round(event.loaded / event.total * 100); } this._progressSubject.next(progress);