I am using exceljs on a node.js server to create and save an excel file for emailing to users. It works well on a local mac machine in development, but on the AWS hosted linux server we're using it produces a problem. The file appears to be written ok, but on trying to open it we receive a warning that the file is corrupt.
The relevant code is:
workbook.xlsx.writeFile(excelFile)
.then(function () {
console.log("Done OK.");
code continues here
Notice that Done OK is never console.logged
My first question is whether the .then(function call takes an error argument which might provide further information on what is happening?
If not any ideas what is going wrong?
If there is a problem with saving to linux filesystem (although it does write fine to our Mac) is there a way to save the file to Amazon S3 storage or even stream it straight to nodemailer for emailing?
When working with promises, you should always have a catch block at the end of the promise chain. Something is likely breaking in when trying to write. There are no problems saving to linux.
Example
workbook.xlsx.writeFile(excelFile)
.then(function () {
console.log("Done OK.");
})
.catch(function (err) {
console.error(err.stack);
});
Is there a way to create an excel file and save it to Amazon S3 storage?
Most helpful comment
Is there a way to create an excel file and save it to Amazon S3 storage?