I\'m trying to package data in memory into a text file and send it to the user, triggering a file download.
I have the following code:
app.get(\'/downloa
app.get('/download', (request, response) => {
const fileData = 'SGVsbG8sIFdvcmxkIQ=='
const fileName = 'hello_world.txt'
const fileType = 'text/plain'
response.writeHead(200, {
'Content-Disposition': `attachment; filename="${fileName}"`,
'Content-Type': fileType,
})
const download = Buffer.from(fileData, 'base64')
response.end(download)
})