From 19d60765ab4bd79a3063b34ddc791256c1a77458 Mon Sep 17 00:00:00 2001 From: Xiujuan Li Date: Sat, 19 Aug 2023 11:27:32 +0800 Subject: [PATCH] feat: fix upload component files show --- javascript/txt2img-config.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/javascript/txt2img-config.js b/javascript/txt2img-config.js index 0d0bea20..72d13310 100644 --- a/javascript/txt2img-config.js +++ b/javascript/txt2img-config.js @@ -315,8 +315,11 @@ function uploadFileChunks(file, presignedUrls, checkpointId, groupName, url, api }; xhr.upload.onprogress = function (event) { - const percentComplete = (event.loaded / event.total) * 100 / totalChunks + currentChunk/totalChunks; - // console.log(`Upload progress: ${percentComplete.toFixed(2)}%`); + // const percentComplete = (event.loaded / event.total) * 100 / totalChunks + currentChunk/totalChunks; + // console.log(`Upload progress: ${percentComplete.toFixed(2)}%`); + const bytesUploaded = currentChunk * chunkSize + event.loaded; + const totalBytes = fileSize; + const percentComplete = (bytesUploaded / totalBytes) * 100; updatePercentProgress(`${percentComplete.toFixed(2)}%`); }; xhr.send(chunk);