multer 2.0.0 buffer is undefined
See original GitHub issueDue to a security vulnerability, I have to upgrade to 2.0.0+ but now req.file.buffer
is undefined. memoryStorage()
is no longer a function, so can you help me figure out how to get the buffer object for my file?
const multer = require('multer');
const storage = multer.memoryStorage() // memoryStorage() is not a function
const upload = multer({ storage: storage })
router.post('/', upload.single('file'), function (req, res, next) {
console.log('file:', req.file) // ok
console.log('path:', req.file.path) // ok
console.log('buffer:', req.file.buffer) // undefined when I don't use memoryStorage
}
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Multer file buffer missing - node.js - Stack Overflow
So when I try to access req.file.buffer it returns undefined. Can someone help to explain. ` const multer = require('multer') ...
Read more >How to upload files in NodeJS using Multer 2.0! - picnature
With Multer 2.0.0, it has become easier than ever to handle uploading logic in your route function. For instance, we already discussed the...
Read more >multer - npm
Start using multer in your project by running `npm i multer`. There are 3538 other projects in the npm registry using multer.
Read more >Express multer middleware
When using memory storage, the file info will contain a field called buffer that contains the entire file. WARNING: Uploading very large files,...
Read more >req.file.path undefined multer - You.com | The AI Search ...
Req.file Is Undefined Multer When working with the Multer library in Node.js, you may encounter the “req.file is undefined” error. This can ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Could you elaborate, would love to fix this in 1.x
That’s correct, we’ve moved to using streams instead of having specific storage engines. To read it into memory, use e.g.
get-stream
:@RegularDan can’t you send the stream directly to imgur, instead of using
getStream
to turn it into a buffer? Something likegot.post('https://imgur.com/api/upload', { body: req.file.stream })
?Anyhow, since the original question have been answered I will close this…