sfcode
An Online Competing and Development Environment
|
Comprehensive MIME type mapping API based on mime-db module.
Install with npm:
npm install mime
npm run test
mime [path_string]
E.g.
> mime scripts/jquery.js application/javascript
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.
Sets the mime type returned when mime.lookup
fails to find the extension searched for. (Default is application/octet-stream
.)
Get the default extension for type
Map mime-type to charset
(The logic for charset lookups is pretty rudimentary. Feel free to suggest improvements.)
Custom type mappings can be added on a per-project basis via the following APIs.
Add custom mime/extension mappings
The first entry in the extensions array is returned by mime.extension()
. E.g.
Load mappings from an Apache ".types" format file
The .types file format is simple - See the types
dir for examples.