arnaucube
arnaucube/raspberryGPIOhtmlserverPublic Self-hosted repository
raspberryGPIOhtmlserver/node_modules/send/node_modules/mime/README.md
node_modules/send/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. 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.extension(type)
24Get the default extension for `type`
25
26    mime.extension('text/html');                 // => 'html'
27    mime.extension('application/octet-stream');  // => 'bin'
28
29### mime.charsets.lookup()
30
31Map mime-type to charset
32
33    mime.charsets.lookup('text/plain');        // => 'UTF-8'
34
35(The logic for charset lookups is pretty rudimentary.  Feel free to suggest improvements.)
36
37## API - Defining Custom Types
38
39The 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/bentomas/node-mime/wiki/Requesting-New-Types).
40
41### mime.define()
42
43Add custom mime/extension mappings
44
45    mime.define({
46        'text/x-some-format': ['x-sf', 'x-sft', 'x-sfml'],
47        'application/x-my-type': ['x-mt', 'x-mtt'],
48        // etc ...
49    });
50
51    mime.lookup('x-sft');                 // => 'text/x-some-format'
52
53The first entry in the extensions array is returned by `mime.extension()`. E.g.
54
55    mime.extension('text/x-some-format'); // => 'x-sf'
56
57### mime.load(filepath)
58
59Load mappings from an Apache ".types" format file
60
61    mime.load('./my_project.types');
62
63The .types file format is simple -  See the `types` dir for examples.