Merged PR 2222: batch uploaded files in blocks of 10 at a time

batch uploaded files in blocks of 10 at a time

Related work items: #22422
This commit is contained in:
Robert Bond
2026-04-02 14:07:20 +00:00
+27 -5
View File
@@ -10,6 +10,7 @@ import fs from "fs";
import path from "path";
const FILENAME_ALLOWED = /^[A-Za-z0-9 ._\-:()—']+$/;
const MAX_FILES_PER_UPLOAD_BATCH = 10;
function validateFilenameServer(originalFilename) {
const name = path.basename(originalFilename || "");
@@ -136,11 +137,32 @@ ApiProxy.post(async (req, res) => {
}
try {
const data = await uploadSingleFile(
allowedFilesFormData,
containerID,
casefolderID
);
const allowedFileEntries = Object.entries(allowedFilesFormData);
const data = [];
for (
let index = 0;
index < allowedFileEntries.length;
index += MAX_FILES_PER_UPLOAD_BATCH
) {
const fileChunk = Object.fromEntries(
allowedFileEntries.slice(
index,
index + MAX_FILES_PER_UPLOAD_BATCH
)
);
const uploadChunkResult = await uploadSingleFile(
fileChunk,
containerID,
casefolderID
);
if (Array.isArray(uploadChunkResult)) {
data.push(...uploadChunkResult);
}
}
return respondSuccess(res, { data, invalidFiles });
} catch (error) {
consoleLogger(error);