From 0f28cdbc3d2f98c27cce5c719ac5075e1f86f09c Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Tue, 17 Apr 2018 13:07:42 +0200 Subject: [PATCH] Improved uploader --- scripts/Utils/fetchWithProgress.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/Utils/fetchWithProgress.ts b/scripts/Utils/fetchWithProgress.ts index b2e990b3..224a61b3 100644 --- a/scripts/Utils/fetchWithProgress.ts +++ b/scripts/Utils/fetchWithProgress.ts @@ -10,8 +10,12 @@ export function fetchWithProgress(url, options: RequestInit, onProgress: ((this: xhr.onload = e => resolve(xhr.responseText) xhr.onerror = reject - if(xhr.upload && onProgress) { - xhr.upload.onprogress = onProgress + if(onProgress) { + xhr.addEventListener("progress", onProgress) + + if(xhr.upload) { + xhr.upload.onprogress = onProgress + } } xhr.send(options.body)