file-is
v1.0.0
Published
Check the type of a file or buffer by inspecting its contents
Downloads
10
Maintainers
Readme
file-is
Check the mime type of a file or binary. A thin wrapper around type-is and mmmagic.
const is = require('file-is')
is('./some/image.png', 'image/*').then(type => console.log(type))
is(new Buffer('something'), 'text/*').then(type => console.log(type))
API
is(String | Buffer | Stream, types...).then( type => )
The first input can be a string for the filename or a buffer/stream for the actual contents. The content can not be a string because then there's no point in using this library.
types
is an array or argument of types.
See typeis.is() for more details.
type
is the first match in the list of types.