Skip to content

Commit

Permalink
Upload chunk: small JS enhancements
Browse files Browse the repository at this point in the history
  • Loading branch information
distantnative committed May 16, 2024
1 parent 56b1630 commit 96f241c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions panel/src/helpers/upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export async function chunked(file, params, size = 5242880) {
for (let i = 0; i < parts; i++) {
const start = i * size;
const end = Math.min(start + size, file.size);
const chunk = file.slice(start, end, file.type);
const chunk = parts > 1 ? file.slice(start, end, file.type) : file;

// when more than one part, add flag to
// recognize chunked upload and its last chunk
Expand All @@ -32,7 +32,7 @@ export async function chunked(file, params, size = 5242880) {
// calculate the total progress based on chunk progress
progress: (xhr, chunk, percent) => {
const total = (i + percent / 100) / parts;
params.progress(xhr, file, Math.ceil(total * 100));
params.progress(xhr, file, Math.round(total * 100));
}
});
}
Expand Down

0 comments on commit 96f241c

Please sign in to comment.