I'm currently working on a project where I need to compress text data into a zip file in memory using TypeScript and then upload it to an AWS S3 bucket. The input data is in plain text CSV format.
However, I seem to be encountering an issue where the zip file created in S3 becomes unreadable when downloaded.
Below is the code snippet:
const zip = new AdmZip();
zip.addFile('tmp.txt', Buffer.from(data, 'utf-8'));
const zipData = await zip.toBufferPromise();
try {
const now = dayjs().format('YYYYMMDDTHHmmss');
const fileName = `Feedback-${now}`;
await this._storageService.saveFile(zipData.toString('binary'), 'sprintFeedback', fileName);