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
This is how you can read a file from S3 nodejs and keep it in memory without first writing the file to some location on disk. It can be used with a combination of S3 and AWS Lambda so that you don't have to write the files to some location on the Lambda.
Remember this processes is asynchronous.
var params = {
Bucket: "",
Key: ""
};
var file = s3.getObject(params).createReadStream();
var buffers = [];
file.on('data', function (data) {
buffers.push(data);
});
file.on('end', function () {
var buffer = Buffer.concat(buffers);
var workbook = xlsx.parse(buffer);
console.log("workbook", workbook)
});