diff --git a/api.planx.uk/modules/send/utils/exportZip.test.ts b/api.planx.uk/modules/send/utils/exportZip.test.ts index cce3cc64ca..48fe1ce7dd 100644 --- a/api.planx.uk/modules/send/utils/exportZip.test.ts +++ b/api.planx.uk/modules/send/utils/exportZip.test.ts @@ -7,7 +7,6 @@ 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 379f1bf9ec..4a15b9bef7 100644 --- a/api.planx.uk/modules/send/utils/exportZip.ts +++ b/api.planx.uk/modules/send/utils/exportZip.ts @@ -193,13 +193,9 @@ export class ExportZip { const s3Key = url.split("/").slice(-2).join("/"); const decodedS3Key = decodeURIComponent(s3Key); const { body } = await getFileFromS3(decodedS3Key); - if (!body) { - throw new Error("file not found"); - } - const filePath = path.join(this.tmpDir, name); - fs.writeFileSync(filePath, body as Buffer); - this.zip.addLocalFile(filePath); - fs.unlinkSync(filePath); + if (!body) throw new Error("file not found"); + + this.zip.addFile(name, body as Buffer); } toBuffer(): Buffer {