Node.js – File System get file type, solution around year 2012

There is a helper library for looking up MIME types: Mime

var mime = require('mime');

mime.getType('/path/to/file.txt'); // => 'text/plain'

But it still uses the extension for lookup though.

Leave a Comment