question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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 as application/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:closed
  • Created 6 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
LinusUcommented, Jul 20, 2017

createReadStream this needs to be create write stream 😃

1reaction
LinusUcommented, Jul 19, 2017
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found