Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

type-files

iwfet582MIT1.0.3

Detect the file type of a base64 The file type is detected by checking the [magic number] of the base64.

base64, mime, type, magic, imagem, img, detect, squiz, matrix, mysource, my, source, files, file, assets

readme

type-files

Detect the file type of a base64 The file type is detected by checking the [magic number] of the base64.

This package is for detecting bas64 based file formats, not binary based formats.

Install

npm install type-files

Usage

Node.js

Determine file type from a file:

import {detectMimeType} from 'type-files';
console.log(detectMimeType('iVBORw0KGgoAAAANSUhEUgAAAAEAAAAB'));
//=> {ext: 'png', mime: 'image/png'}