npm.io
0.0.1 • Published 5 years ago

file-identity

Licence
MIT
Version
0.0.1
Deps
0
Size
48 kB
Vulns
0
Weekly
0
Stars
2

file-identity

Build Status codecov

The file type is detected by checking the magic number of the buffer.

Install

$ yarn add file-identity
$ npm install file-identity --save
Methods
FT.fromFile(file)
FT.fromBuffer(buffer)
Usage

Take Vue for example

html

<input type="file" @input="handleFileInput" />

js

import FT from 'file-identity'

async handleFileInput(event) {
  const result = await FT.fromFile(event.target.files[0])
  console.log(result)
}