batch uploaded files in blocks of 10 at a time
This commit is contained in:
@@ -10,6 +10,7 @@ import fs from "fs";
|
|||||||
import path from "path";
|
import path from "path";
|
||||||
|
|
||||||
const FILENAME_ALLOWED = /^[A-Za-z0-9 ._\-:()—']+$/;
|
const FILENAME_ALLOWED = /^[A-Za-z0-9 ._\-:()—']+$/;
|
||||||
|
const MAX_FILES_PER_UPLOAD_BATCH = 10;
|
||||||
|
|
||||||
function validateFilenameServer(originalFilename) {
|
function validateFilenameServer(originalFilename) {
|
||||||
const name = path.basename(originalFilename || "");
|
const name = path.basename(originalFilename || "");
|
||||||
@@ -136,11 +137,32 @@ ApiProxy.post(async (req, res) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const data = await uploadSingleFile(
|
const allowedFileEntries = Object.entries(allowedFilesFormData);
|
||||||
allowedFilesFormData,
|
const data = [];
|
||||||
containerID,
|
|
||||||
casefolderID
|
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 });
|
return respondSuccess(res, { data, invalidFiles });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
consoleLogger(error);
|
consoleLogger(error);
|
||||||
|
|||||||
Reference in New Issue
Block a user