Fix file upload progress.

This commit is contained in:
Jared Goodwin 2020-08-08 15:54:51 -07:00
parent 6eb2f5f1bc
commit 29df1df67b
3 changed files with 18 additions and 7 deletions

View File

@ -392,9 +392,13 @@ function uploadFiles(fileList) {
AddConsoleOutput("File upload failed.");
reject();
});
xhr.addEventListener("progress", function (e) {
AddConsoleOutput("File upload progress: " + String(isFinite(e.loaded / e.total) ? e.loaded / e.total : 0) + "%");
});
xhr.upload.onprogress = (e) => {
var currentPercent = isFinite(e.loaded / e.total) ? Math.round(e.loaded / e.total * 100) : 0;
if (currentPercent != uploadPercent) {
var uploadPercent = currentPercent;
AddConsoleOutput("File upload progress: " + String(currentPercent) + "%");
}
};
xhr.send(fd);
});
}

File diff suppressed because one or more lines are too long

View File

@ -537,9 +537,16 @@ function uploadFiles(fileList: FileList): Promise<string[]> {
AddConsoleOutput("File upload failed.");
reject();
});
xhr.addEventListener("progress", function (e) {
AddConsoleOutput("File upload progress: " + String(isFinite(e.loaded / e.total) ? e.loaded / e.total : 0) + "%");
});
xhr.upload.onprogress = (e) => {
var currentPercent = isFinite(e.loaded / e.total) ? Math.round(e.loaded / e.total * 100) : 0;
if (currentPercent != uploadPercent) {
var uploadPercent = currentPercent;
AddConsoleOutput("File upload progress: " + String(currentPercent) + "%");
}
};
xhr.send(fd);
})