mime / 1.2.11 last updated a year ago created on Jan 20th 2011
Install
npm install --save mime
Clone
git clone git@github.com:broofa/node-mime.git
dependencies
No dependencies listed.
maintainers
versions
| 1.2.11 | a year ago | broofa |
| 1.2.6 | 2 years ago | bentomas |
| 1.2.5 | 3 years ago | broofa |
readme
mime
Comprehensive MIME type mapping API. Includes all 600+ types and 800+ extensions defined by the Apache project, plus additional types submitted by the node.js community.
Install
Install with npm:
API - Queries
mime.lookup(path)
Get the mime type associated with a file, if no mime type is found application/octet-stream is returned. Performs a case-insensitive lookup using the extension in path (the substring after the last '/' or '.'). E.g.
mime.default_type
Sets the mime type returned when mime.lookup fails to find the extension searched for. (Default is application/octet-stream.)
mime.extension(type)
Get the default extension for type
mime.charsets.lookup()
Map mime-type to charset
(The logic for charset lookups is pretty rudimentary. Feel free to suggest improvements.)
API - Defining Custom Types
The following APIs allow you to add your own type mappings within your project. If you feel a type should be included as part of node-mime, see requesting new types.
mime.define()
Add custom mime/extension mappings
The first entry in the extensions array is returned by mime.extension(). E.g.
mime.load(filepath)
Load mappings from an Apache ".types" format file
The .types file format is simple - See the types dir for examples.