Skip to content

通过检查 Buffer 中的魔数(magic number)来检测文件类型

License

Notifications You must be signed in to change notification settings

MrLeihe/file-identity

Repository files navigation

file-identity

npm version 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)
}

About

通过检查 Buffer 中的魔数(magic number)来检测文件类型

Resources

License

Stars

Watchers

Forks

Packages

No packages published