Fixed file uploads performance issues (#1562)

This commit is contained in:
Mateo Gallardo 2024-02-12 15:18:01 -03:00 committed by GitHub
parent 808af3c19a
commit 64487ad923
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -15,11 +15,12 @@ const parseFormData = (datas, collectionPath) => {
const filePaths = value || [];
filePaths.forEach((filePath) => {
let trimmedFilePath = filePath.trim();
if (!path.isAbsolute(trimmedFilePath)) {
trimmedFilePath = path.join(collectionPath, trimmedFilePath);
}
const file = fs.readFileSync(trimmedFilePath);
form.append(name, file, path.basename(trimmedFilePath));
form.append(name, fs.createReadStream(trimmedFilePath), path.basename(trimmedFilePath));
});
} else {
form.append(name, value);