From d9b70e0017c406eef614e79b07b7ce5ff5a92e65 Mon Sep 17 00:00:00 2001 From: Jessica McInchak Date: Fri, 6 Dec 2024 11:03:30 +0100 Subject: [PATCH] fix: ensure empty JSON files aren't written to S3 (#4048) --- api.planx.uk/modules/file/service/uploadFile.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api.planx.uk/modules/file/service/uploadFile.ts b/api.planx.uk/modules/file/service/uploadFile.ts index ead3cee9af..a6ee74227b 100644 --- a/api.planx.uk/modules/file/service/uploadFile.ts +++ b/api.planx.uk/modules/file/service/uploadFile.ts @@ -79,9 +79,9 @@ export function generateFileParams( ACL: "public-read", Bucket: process.env.AWS_S3_BUCKET, Key: key, - Body: file.buffer, + Body: file.buffer || JSON.stringify(file), ContentDisposition: `inline;filename="${filename}"`, - ContentType: file.mimetype, + ContentType: file.mimetype || "application/json", }; return {