🔨 So far it only detects popular image/audio/application types, new types will be added as time goes by and/or we have help.
This package is inspired by file-type and uses the file signature as the basis for determining its type.
- zero dependency
- detects quickly and synchronously
Node.js
npm i buffer-file-signature
# or
yarn add buffer-file-signature
Detects by base64 ( only so far )
const file = BufferFileSignature.fromBase64('4AAQSkZJRgA...')
file.extension()
/*
example output: {
ext: 'jpg',
mime: 'image/jpeg',
types: ['jpg', 'jpeg', 'jfif']
}
*/
file.size()
/*
example output: 512000 // bytes
*/
Help method for formatting size
const file = BufferFileSignature.formatSize(512000)
/*
example output: 500 KB
*/