Indeed, it is unfortunate that most popular MIME modules simply display a type extension.
After searching deeper, I found a module called mmmagic , it seems to do exactly what you want.
Keep in mind that from working with MIME I have remained tasteful that the detection of MIME in principle is not completely reliable, and there is a rare chance of false positives.
Usage example (taken from their site):
var mmm = require('mmmagic'), Magic = mmm.Magic; var magic = new Magic(mmm.MAGIC_MIME_TYPE); magic.detectFile('node_modules/mmmagic/build/Release/magic.node', function(err, result) { if (err) throw err; console.log(result);
source share