diff --git a/app/routes/report.tsx b/app/routes/report.tsx index 2e6c1ef..52198ed 100644 --- a/app/routes/report.tsx +++ b/app/routes/report.tsx @@ -184,8 +184,9 @@ export default function () { xhr.upload.onprogress = (e) => { if (!e.lengthComputable) return; - bytesRead += e.loaded; - setFileProgress(Math.floor((bytesRead / totalSize) * 100)); + setFileProgress( + Math.floor(((bytesRead + e.loaded) / totalSize) * 100), + ); }; xhr.upload.onabort = () => { shouldRecall = true; @@ -197,9 +198,11 @@ export default function () { setUploading(false); setFileProgress(0); }; - xhr.upload.onloadend = () => { + xhr.upload.onloadend = (ev) => { if (i === upload_urls.length - 1) setUploading(false); + bytesRead += ev.total; + setFileProgress(bytesRead); resolve(null); };