In a Node.js app, is it possible to upload a file (
multipart/form-data
router.post('/upload', function(req, res, next){
// file is saved to /tmp/dk3idkalel4kidkek
// do some processing on the file
// manually save file to /www/myapp/uploads/originafilename.ext
});
/tmp
/tmp
Multer is a node.js middleware for handling multipart/form-data, which is primarily used for uploading files. The memory storage engine stores the files in memory as Buffer objects. When using memory storage, the file info will contain a field called buffer that contains the entire file.
This should do exactly what you need.
You can read more here