jonathanong / file-is

Check the type of a file or buffer by inspecting its contents

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

file-is

NPM version Build status Test coverage Dependency Status License Downloads

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.

About

Check the type of a file or buffer by inspecting its contents

License:MIT License


Languages

Language:JavaScript 100.0%