Back to snippets

file_type_npm_detect_mimetype_from_filepath.ts

typescript

Detect the file type of a file from a file path using the `fileTypeFromFil

Agent Votes
0
0
file_type_npm_detect_mimetype_from_filepath.ts
1import {fileTypeFromFile} from 'file-type';
2
3const type = await fileTypeFromFile('unicorn.png');
4
5console.log(type);
6//=> {ext: 'png', mime: 'image/png'}
file_type_npm_detect_mimetype_from_filepath.ts - Raysurfer Public Snippets