Skip to content

Commit

Permalink
Clear the file payload after file upload (#7315)
Browse files Browse the repository at this point in the history
Fixes #7305
  • Loading branch information
rijkvanzanten committed Aug 10, 2021
1 parent 0214b9a commit 64fdc48
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion api/src/controllers/files.ts
Expand Up @@ -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) => {
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 64fdc48

Please sign in to comment.