Clear the file payload after file upload (#7315)

Fixes #7305
This commit is contained in:
Rijk van Zanten
2021-08-10 16:14:51 +02:00
committed by GitHub
parent 0214b9a1bb
commit 64fdc48ade

View File

@@ -33,7 +33,7 @@ const multipartHandler = asyncHandler(async (req, res, next) => {
*/
let disk: string = toArray(env.STORAGE_LOCATIONS)[0];
const payload: Partial<File> = {};
let payload: Partial<File> = {};
let fileCount = 0;
busboy.on('field', (fieldname: keyof File, val) => {
@@ -70,6 +70,9 @@ const multipartHandler = asyncHandler(async (req, res, next) => {
storage: payload.storage || disk,
};
// Clear the payload for the next to-be-uploaded file
payload = {};
try {
const primaryKey = await service.uploadOne(fileStream, payloadWithRequiredFields, existingPrimaryKey);
savedFiles.push(primaryKey);