Incorrect mimetype on windows, works fine on osx
See original GitHub issue- I have tried to upload the same file using two chrome browsers one on windows and the other on osx. The windows one shows mimetype as
application/ocetet-stream
and the osx one shows asapplication/zip
. This is wierd and not sure the root cause.
Logs to give insights
- On windows
req.file.originalname : sample_input.zip
req.file.encoding : 7bit
req.file.size : 2020
req.file.mimetype : application/octet-stream
- on OSX
req.file.originalname : sample_input.zip
req.file.encoding : 7bit
req.file.size : 2020
req.file.mimetype : application/zip
My code
var storage = multer.diskStorage({
destination: function(req, file, cb) {
cb(null, Upload_measurements_dir)
},
filename: function(req, file, cb) {
crypto.pseudoRandomBytes(16, function(err, raw) {
cb(null, raw.toString('hex') + Date.now() + '.' + mime.extension(file.mimetype));
});
}
});
var upload = multer({
storage: storage,
limits: {
fileSize: config.maxSize
}
});
var UploadSettings = upload.single('data');
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
Any fix for wrong mime type encoding for outgoing attachments?
If an attachment is received (or is in a mailbox) that has the correct mime type then it can be dragged to another...
Read more >Wrong MIME type - Microsoft Community
Wrong MIME type. Both .doc and .dotx files being saved out of Word for Mac have the same MIME type. Template files should...
Read more >MacOS and Linux use MIME and Not File Extensions - Medium
Which works just fine if you know what you're doing. The Shared MIME type as it's called from freedesktop.org isn't always reliable because...
Read more >Wrong mime type in windows browser for text/csv files
I am using file object to determine the mime type of file. This process works very well on Linux and Mac but in...
Read more >MIME Types Explained: Why Linux and Mac OS X Don't Need ...
In some cases, a server may have incorrect MIME type settings configured. This is why you'll sometimes click a link on a web...
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 FreeTop 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
Top GitHub Comments
createReadStream
this needs to be create write stream 😃The new documentation is here: https://github.com/expressjs/multer/blob/c4b223efc4730611f7c6bfe9608bfd4048e3754d/README.md
😃