I need a service to download an excel file from Amazon S3, then parse with node-xlsx
The problem is that I can\'t get xlsx to parse the file. When I try to read back
The node-xlsx module requires that the entire xlsx buffer be available. So you cannot pass it a ReadStream like you're currently doing. Try this method which entirely avoids writing to disk:
router.get('/process', (req, res) => {
var fileName = 'https://some-bucket.s3.amazonaws.com/some-excel-file.xlsx'
https.get(fileName, response => {
var chunks = []
response.on('data', chunk => chunks.push(chunk))
.on('end', () => {
var book = xlsx.parse(Buffer.concat(chunks))
book.forEach(sheet => console.log('sheet', sheet.name))
res.status(200)
})
.on('error', e => {
res.status(500)
})
})
return
})