Nodejs - retrieving remote file and detect mime-type

So, this is my problem. I read from some APIs a URL that points to a file. The only thing I know about this file is that it is a file... but I would like to detect what kind of file this is. The URL is not helping since it is encoded in base64 (I guess) and so I have no file name or extension I could use for my scope.

I have tried to use node-mime module (https://github.com/broofa/node-mime) but what I get is application/octet-stream which is not that much useful in detecting the real type of the file.

The aim is to display "in browser" the files that the browser is able to handle without requiring the user to download them.

Thanks!

Use mmmagic to determine the mime type.

https://npmjs.org/package/mmmagic

If you want to display the files in browser itself without the need to download use 'Content-Disposition: inline' header.

mmmagic will work, but requires an external library (libmagic) or Python equivalent. This presents problems if you do not want to install Python on your Windows machine. It would be nice to have a pure node version of libmagic.