Im has a node application with an expression that uses the multer module
https://github.com/expressjs/multer
in the file app.js
I put the following:
var mulStorage = require("./utils/store"),
var upload = multer({
storage: mul.storage,
dest: 'uploads/'
});
app.use(upload.single('file'));
The file is store.js
as follows
var multer = require('multer');
var stor = multer.diskStorage({
destination: function (req, file, cb) {
cb(null, './uploads/')
},
filename: function (req, file, cb) {
var filename = file.originalname;
var fileExtension = filename.split(".")[1];
cb(null, Date.now() + "." + fileExtension);
}
})
module.exports = {
stor: stor
}
When I run a query using a mailbox, I received the following error:
Error: ENOENT: there is no such file or directory, open 'C: \ Users \ c45669 \ WebstormProjects \ App \ downloads \ 1454935327214.zip'
on error (native)
Why doesn't multer create a folder if it does not exist?
If I create a download folder in the root directory manually , this works ...
BTW,
storage: mul.storage,
, ...
var upload = multer({
dest: 'uploads/'
});
dest multer , ...