DEV Community

Discussion on: Generate a PDF in AWS Lambda with NodeJS and Puppeteer

Collapse
 
akirautio profile image
Aki Rautio

I haven't done this with PDF but I have another lambda function save files which I save this way. Though you could also put the PDF variable straight to body before turning it to base64 and that should work.

const s3 = new AWS.S3()

s3.upload(
{
Body: Buffer.from(pdfBase64, 'base64'),
Bucket: BUCKET,
Key: 'path for the file'
},
(err, data) => {
if (err) {
callback(err, null)
} else {
callback(null, {
statusCode: 200,
body: true,
isBase64Encoded: false
})
}
}
)