V
V
Vladimir Kudinov2012-05-14 19:02:40
JavaScript
Vladimir Kudinov, 2012-05-14 19:02:40

File mime type in Node.js

How to determine the mime type of a file in Node.js using standard modules?

I must say right away that I just started learning Node and I may not know the obvious things, but Google and the documentation did not help.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
iStyx, 2012-05-14
@frux

var execFile = require('child_process').execFile;
var filename = ...;
execFile('file',['-b','--mime-type',filename],function(error,stdout,stderr) {
    console.log("STDOUT:",stdout.trim());
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question