arnaucube
arnaucube/comunicationLeapPublic Self-hosted repository
comunicationLeap/node_modules/mime/README.md
node_modules/mime/README.mdRaw
 1# mime
 2
 3Comprehensive 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.
 4
 5## Install
 6
 7Install with [npm](http://github.com/isaacs/npm):
 8
 9    npm install mime
10
11## API - Queries
12
13### mime.lookup(path)
14Get 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.
15
16    var mime = require('mime');
17
18    mime.lookup('/path/to/file.txt');         // => 'text/plain'
19    mime.lookup('file.txt');                  // => 'text/plain'
20    mime.lookup('.TXT');                      // => 'text/plain'
21    mime.lookup('htm');                       // => 'text/html'
22
23### mime.default_type
24Sets the mime type returned when `mime.lookup` fails to find the extension searched for. (Default is `application/octet-stream`.)
25
26### mime.extension(type)
27Get the default extension for `type`
28
29    mime.extension('text/html');                 // => 'html'
30    mime.extension('application/octet-stream');  // => 'bin'
31
32### mime.charsets.lookup()
33
34Map mime-type to charset
35
36    mime.charsets.lookup('text/plain');        // => 'UTF-8'
37
38(The logic for charset lookups is pretty rudimentary.  Feel free to suggest improvements.)
39
40## API - Defining Custom Types
41
42The 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](https://github.com/broofa/node-mime/wiki/Requesting-New-Types).
43
44### mime.define()
45
46Add custom mime/extension mappings
47
48    mime.define({
49        'text/x-some-format': ['x-sf', 'x-sft', 'x-sfml'],
50        'application/x-my-type': ['x-mt', 'x-mtt'],
51        // etc ...
52    });
53
54    mime.lookup('x-sft');                 // => 'text/x-some-format'
55
56The first entry in the extensions array is returned by `mime.extension()`. E.g.
57
58    mime.extension('text/x-some-format'); // => 'x-sf'
59
60### mime.load(filepath)
61
62Load mappings from an Apache ".types" format file
63
64    mime.load('./my_project.types');
65
66The .types file format is simple -  See the `types` dir for examples.