I'm triying to upload an excel file with postman and save it in to a folder with node.js
fs
:
var file = req.body.file;
fs.writeFile("public/myExcelFile.xlsx", file, function(err) {
if(err) {
res.json(err);
} else {
res.json("The file was saved!");
}
});
But when I try to open the file after upload it is corrupt or empty, can you tell me pls what im doing wrong?
In the future I have to upload another files like .docx or .csv so I want to know what is the best way to save these files, it's better save files in database(I´m using Sql server) as a blob
? or save the file in a folder and save the path in database?