node js get file type code example
Example 1: how to check file extension in node js
var path = require('path');
var ext = path.extname('/Users/Refsnes/demo_path.js');
console.log(ext);
Example 2: File type node js
const FileType = require('file-type');
(async () => {
console.log(await FileType.fromFile('Unicorn.png'));
//=> {ext: 'png', mime: 'image/png'}
})();