From 047c8b7f1045bd50327eec91573798cb9e04ea8e Mon Sep 17 00:00:00 2001 From: Jessica McInchak Date: Tue, 21 Nov 2023 12:00:00 +0000 Subject: [PATCH] Revert "chore: Stream S3 files directly to zip (#2380)" (#2469) This reverts commit 96adf166cd722befb989a81c64c23530fdaf8c53. --- api.planx.uk/modules/send/utils/exportZip.test.ts | 1 + api.planx.uk/modules/send/utils/exportZip.ts | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/api.planx.uk/modules/send/utils/exportZip.test.ts b/api.planx.uk/modules/send/utils/exportZip.test.ts index 48fe1ce7dd..cce3cc64ca 100644 --- a/api.planx.uk/modules/send/utils/exportZip.test.ts +++ b/api.planx.uk/modules/send/utils/exportZip.test.ts @@ -7,6 +7,7 @@ jest.mock("fs", () => ({ existsSync: () => true, unlinkSync: () => undefined, createWriteStream: () => undefined, + writeFileSync: () => undefined, rmSync: () => undefined, })); diff --git a/api.planx.uk/modules/send/utils/exportZip.ts b/api.planx.uk/modules/send/utils/exportZip.ts index 3cfec11cca..379f1bf9ec 100644 --- a/api.planx.uk/modules/send/utils/exportZip.ts +++ b/api.planx.uk/modules/send/utils/exportZip.ts @@ -197,7 +197,9 @@ export class ExportZip { throw new Error("file not found"); } const filePath = path.join(this.tmpDir, name); - this.zip.addFile(filePath, body as Buffer); + fs.writeFileSync(filePath, body as Buffer); + this.zip.addLocalFile(filePath); + fs.unlinkSync(filePath); } toBuffer(): Buffer {