All Projects → jshttp → Mime Types

jshttp / Mime Types

Licence: mit
The ultimate javascript content-type utility.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Mime Types

Mime
The Hoa\Mime library.
Stars: ✭ 100 (-88.44%)
Mutual labels:  mime, mime-types
Mime
.NET wrapper for libmagic
Stars: ✭ 51 (-94.1%)
Mutual labels:  mime, mime-types
Filetype
Fast, dependency-free, small Go package to infer the binary file type based on the magic numbers signature
Stars: ✭ 1,278 (+47.75%)
Mutual labels:  mime, mime-types
Mime
Shared MIME-info database in D programming language
Stars: ✭ 7 (-99.19%)
Mutual labels:  mime, mime-types
mimesniff
MIME Sniffing Standard
Stars: ✭ 89 (-89.71%)
Mutual labels:  mime, mime-types
Swime
🗂 Swift MIME type checking based on magic bytes
Stars: ✭ 119 (-86.24%)
Mutual labels:  mime, mime-types
Mime Db
Media Type Database
Stars: ✭ 612 (-29.25%)
Mutual labels:  mime, mime-types
Fileio.jl
Main Package for IO, loading all different kind of files
Stars: ✭ 133 (-84.62%)
Mutual labels:  mime, mime-types
ruby-magic
Simple interface to libmagic for Ruby Programming Language
Stars: ✭ 23 (-97.34%)
Mutual labels:  mime, mime-types
Mimetype
A fast golang library for MIME type and file extension detection, based on magic numbers
Stars: ✭ 452 (-47.75%)
Mutual labels:  mime, mime-types
safe-svg
Enable SVG uploads and sanitize them to stop XML/SVG vulnerabilities in your WordPress website.
Stars: ✭ 129 (-85.09%)
Mutual labels:  mime
php-mime-detector
Detect a file's mime type using magic numbers.
Stars: ✭ 20 (-97.69%)
Mutual labels:  mime
Filepicker
🔥🔥🔥Android文件、图片选择器,可按文件夹查找,文件类型查找,支持自定义相机
Stars: ✭ 265 (-69.36%)
Mutual labels:  mime-types
Mailkit
A cross-platform .NET library for IMAP, POP3, and SMTP.
Stars: ✭ 4,477 (+417.57%)
Mutual labels:  mime
mimeparse-php
Basic functions for handling mime-types, forked from Joe Gregorio's mimeparse library
Stars: ✭ 38 (-95.61%)
Mutual labels:  mime
adif
用标准c语言开发的常用数据结构和算法基础库,作为应用程序开发接口基础库,为编写高性能程序提供便利,可极大地缩短软件项目的开发周期,提升工程开发效率,并确保软件系统运行的可靠性、稳定性。
Stars: ✭ 33 (-96.18%)
Mutual labels:  mime
mimesniffer
A MIME type sniffer for Go.
Stars: ✭ 22 (-97.46%)
Mutual labels:  mime
Mail
Library to send e-mails over different transports and protocols (like SMTP and IMAP) using immutable messages and streams. Also includes SMTP server.
Stars: ✭ 399 (-53.87%)
Mutual labels:  mime
fs2-mail
asynchronous library for sending and receiving mail via fs2._
Stars: ✭ 39 (-95.49%)
Mutual labels:  mime
AdES
An Implementation of CAdES, XAdES, PAdES and ASiC for Windows in C++
Stars: ✭ 29 (-96.65%)
Mutual labels:  mime

mime-types

NPM Version NPM Downloads Node.js Version Build Status Test Coverage

The ultimate javascript content-type utility.

Similar to the [email protected] module, except:

  • No fallbacks. Instead of naively returning the first available type, mime-types simply returns false, so do var type = mime.lookup('unrecognized') || 'application/octet-stream'.
  • No new Mime() business, so you could do var lookup = require('mime-types').lookup.
  • No .define() functionality
  • Bug fixes for .lookup(path)

Otherwise, the API is compatible with mime 1.x.

Install

This is a Node.js module available through the npm registry. Installation is done using the npm install command:

$ npm install mime-types

Adding Types

All mime types are based on mime-db, so open a PR there if you'd like to add mime types.

API

var mime = require('mime-types')

All functions return false if input is invalid or not found.

mime.lookup(path)

Lookup the content-type associated with a file.

mime.lookup('json') // 'application/json'
mime.lookup('.md') // 'text/markdown'
mime.lookup('file.html') // 'text/html'
mime.lookup('folder/file.js') // 'application/javascript'
mime.lookup('folder/.htaccess') // false

mime.lookup('cats') // false

mime.contentType(type)

Create a full content-type header given a content-type or extension. When given an extension, mime.lookup is used to get the matching content-type, otherwise the given content-type is used. Then if the content-type does not already have a charset parameter, mime.charset is used to get the default charset and add to the returned content-type.

mime.contentType('markdown') // 'text/x-markdown; charset=utf-8'
mime.contentType('file.json') // 'application/json; charset=utf-8'
mime.contentType('text/html') // 'text/html; charset=utf-8'
mime.contentType('text/html; charset=iso-8859-1') // 'text/html; charset=iso-8859-1'

// from a full path
mime.contentType(path.extname('/path/to/file.json')) // 'application/json; charset=utf-8'

mime.extension(type)

Get the default extension for a content-type.

mime.extension('application/octet-stream') // 'bin'

mime.charset(type)

Lookup the implied default charset of a content-type.

mime.charset('text/markdown') // 'UTF-8'

var type = mime.types[extension]

A map of content-types by extension.

[extensions...] = mime.extensions[type]

A map of extensions by content-type.

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].