Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mime-sniffer

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mime-sniffer

A mime sniffer that uses file magic numbers rather than unsecure extensions.

  • 0.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

mime-sniffer

A little utility to get the mime-type from binary files.

Unlike mime, mime-sniffer uses magic numbers instead of file extensions to get a more accurate (and less easily faked) mime-type for a given file.

Install

npm install mime-sniffer --save

Usage

var mime = require('mime-sniffer');
mime.lookup('/path/to/file.jpg', function(err, info) {
	console.log(info); // { mime: 'image/jpeg', extension: 'jpg' }
});

You can also pass in a Buffer:

var fs = require('fs');
var mime = require('mime-sniffer');
mime.lookup(fs.readFileSync('/path/to/file.jpg'), function(err, info) {
	console.log(info); // { mime: 'image/jpeg', extension: 'jpg' }
});

Supported files

To see what file types are supported, take a peek in the lib/numbers.js file.

Currently, mime-sniffer supports:

Images
  • gif
  • png
  • jpg
  • webp
  • tiff
  • bmp
Video
  • mp4
  • mov
  • webm
Audio
  • mp3
  • ogg
  • flac
  • wav
Misc
  • pdf

License

MIT

Keywords

FAQs

Package last updated on 14 Jan 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc