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 {