Process files sequentially to avoid too many simultaneous requests
This commit is contained in:
parent
d775b8be72
commit
e472850f83
|
@ -338,8 +338,7 @@ Oqtane.Interop = {
|
||||||
progressbar.value = 0;
|
progressbar.value = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const uploadFiles = Array.from(fileinput.files).map(file => {
|
const uploadFile = (file) => {
|
||||||
const uploadFile = () => {
|
|
||||||
const chunkSize = chunksize * (1024 * 1024);
|
const chunkSize = chunksize * (1024 * 1024);
|
||||||
const totalParts = Math.ceil(file.size / chunkSize);
|
const totalParts = Math.ceil(file.size / chunkSize);
|
||||||
let partCount = 0;
|
let partCount = 0;
|
||||||
|
@ -398,7 +397,7 @@ Oqtane.Interop = {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
function processNextUpload() {
|
function processNextUpload() {
|
||||||
if (partCount >= totalParts) {
|
if (partCount >= totalParts) {
|
||||||
if (activeUploads === 0) resolve(); // Done uploading all parts
|
if (activeUploads === 0) resolve(); // Done uploading all parts in the file
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -419,11 +418,10 @@ Oqtane.Interop = {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
return uploadFile();
|
|
||||||
});
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await Promise.all(uploadFiles);
|
for (const file of fileinput.files) {
|
||||||
|
await uploadFile(file);
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
success = false;
|
success = false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user