You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The problem is that file.size remains undefined. I control that the size exists before sending the files to the API. When I check which properties are available (see the console.log), I only have 'fieldname', 'originalname', 'encoding', 'mimetype'.
If I use +req.headers["content-length"] it takes into account the size of all the request (all the files), and not only the current file.
Why can't I have the file size? Is it impossible or should I edit some setting I haven't found in the documentation?
I think it's because multer is base on busboy, and there could be a way from here:
Either busboy gives the size (I opened an issue here: mscdex/busboy#354), or multer can estimate the size with the filestream. That would be a good solution, in my opinion.
The text was updated successfully, but these errors were encountered:
storage.filename callback arguments are based on request content disposition header: filename, content-type etc. In multer().single() middleware the file is already being uploaded and you can have more detailed file stats
outStream.on('finish',function(){cb(null,{destination: destination,filename: filename,path: finalPath,size: outStream.bytesWritten// actual filesize stat from the finished stream})})
I'm using multer to handle a multi-file upload, and the middleware "filename", like this:
The problem is that
file.size
remains undefined. I control that the size exists before sending the files to the API. When I check which properties are available (see theconsole.log
), I only have'fieldname', 'originalname', 'encoding', 'mimetype'
.If I use
+req.headers["content-length"]
it takes into account the size of all the request (all the files), and not only the current file.Why can't I have the file size? Is it impossible or should I edit some setting I haven't found in the documentation?
I think it's because multer is base on busboy, and there could be a way from here:
multer/lib/make-middleware.js
Line 97 in aa42bea
Either busboy gives the size (I opened an issue here: mscdex/busboy#354), or multer can estimate the size with the
filestream
. That would be a good solution, in my opinion.The text was updated successfully, but these errors were encountered: