-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The file
object doesn't contain much info
#333
Comments
Could you please share the code that you are using? |
I am having a similar issue. So far I found what line the file is being created. var storage = multer.diskStorage({
destination: function (req, file, cb) {
cb(null, './uploads/')
},
filename: function (req, file, cb) {
cb(null, "" + '-' + Date.now())
console.log(req.body);
console.log(file);
/*
{ }
{ fieldname: 'image',
originalname: 'ekeitho.jpg',
encoding: '7bit',
mimetype: 'image/jpeg' } */
}
});
var upload = multer({dest: './uploads/', storage: storage});
app.post('/pictures', upload.single('image'), function(req,res) {
req.file.filename = req.body.filename;
}); |
Okay, I reread the first question again and realised that I missed where it was the first time. @mercmobily That is expected behaviour since we can't know the size of the file before it has been uploaded. We also can't know the destination before the destination has been set, what do you think that @ekeitho You have a totally different problem that is mentioned in the documentation. This has come up a number of times before, e.g. #146 where the workaround is outlined...
In addition to that, you can't just change the |
My apologies for not responding quicker.
|
When control is handed over to your route handler const upload = multer(/* ... */).single('file')
app.post('/test', upload, function (req, res, next) {
// Here everything will be populated
}) |
I have this in my server.js: var multer = require('multer') ... // Needs to be logged in for this to work // Here, 'file' is not populated I can send you a minimal server.js to show it, but that's what's happening Merc. ᐧ On 5 April 2016 at 16:06, Linus Unnebäck notifications@github.com wrote:
|
(It also happens with On 6 April 2016 at 10:50, Tony Mobily merc@mobily1.com wrote:
|
I am using the DiskStorage backend.
My
file
object in all of the important callbacks (filter
,destination
, etc.) only has the following properties:In your documentation, you state:
Each file contains the following information:
fieldname
originalname
encoding
mimetype
size
destination
DiskStorage
filename
destination
DiskStorage
path
DiskStorage
buffer
Buffer
of the entire fileAm I doing something wrong?
The text was updated successfully, but these errors were encountered: