Looking to send a local zip file over http from an AWS TypeScipt Lambda, as shown below:
exports.handler = async function (event: any) {
let zip = readZip()
return {
statusCode: 200,
headers: { "Content-Type": "application/zip", "Content-Dispostion": "attachment; filename=filename.zip" },
body: zip
}
}
After trying various methods, the closest I got was using fs.readFileSync() to read the zip file, but it resulted in a slightly corrupted file that cannot be unzipped.
Attempts with JSZip and JSZipUtils, decoding base64 strings, and converting byte buffers have all failed. The goal is to directly deliver the file as an APIGateway response without hosting it on an S3 bucket for download.
Any suggestions or insights on how to achieve this successfully?