You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

76 lines
2.6 KiB

8 years ago
  1. # mime-db
  2. [![NPM Version][npm-version-image]][npm-url]
  3. [![NPM Downloads][npm-downloads-image]][npm-url]
  4. [![Node.js Version][node-image]][node-url]
  5. [![Build Status][travis-image]][travis-url]
  6. [![Coverage Status][coveralls-image]][coveralls-url]
  7. This is a database of all mime types.
  8. It consists of a single, public JSON file and does not include any logic,
  9. allowing it to remain as un-opinionated as possible with an API.
  10. It aggregates data from the following sources:
  11. - http://www.iana.org/assignments/media-types/media-types.xhtml
  12. - http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types
  13. ## Installation
  14. ```bash
  15. npm install mime-db
  16. ```
  17. If you're crazy enough to use this in the browser,
  18. you can just grab the JSON file:
  19. ```
  20. https://cdn.rawgit.com/jshttp/mime-db/master/db.json
  21. ```
  22. ## Usage
  23. ```js
  24. var db = require('mime-db');
  25. // grab data on .js files
  26. var data = db['application/javascript'];
  27. ```
  28. ## Data Structure
  29. The JSON file is a map lookup for lowercased mime types.
  30. Each mime type has the following properties:
  31. - `.source` - where the mime type is defined.
  32. If not set, it's probably a custom media type.
  33. - `apache` - [Apache common media types](http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types)
  34. - `iana` - [IANA-defined media types](http://www.iana.org/assignments/media-types/media-types.xhtml)
  35. - `.extensions[]` - known extensions associated with this mime type.
  36. - `.compressible` - whether a file of this type is can be gzipped.
  37. - `.charset` - the default charset associated with this type, if any.
  38. If unknown, every property could be `undefined`.
  39. ## Contributing
  40. To edit the database, only make PRs against `src/custom.json` or
  41. `src/custom-suffix.json`.
  42. To update the build, run `npm run update`.
  43. ## Adding Custom Media Types
  44. The best way to get new media types included in this library is to register
  45. them with the IANA. The community registration procedure is outlined in
  46. [RFC 6838 section 5](http://tools.ietf.org/html/rfc6838#section-5). Types
  47. registered with the IANA are automatically pulled into this library.
  48. [npm-version-image]: https://img.shields.io/npm/v/mime-db.svg
  49. [npm-downloads-image]: https://img.shields.io/npm/dm/mime-db.svg
  50. [npm-url]: https://npmjs.org/package/mime-db
  51. [travis-image]: https://img.shields.io/travis/jshttp/mime-db/master.svg
  52. [travis-url]: https://travis-ci.org/jshttp/mime-db
  53. [coveralls-image]: https://img.shields.io/coveralls/jshttp/mime-db/master.svg
  54. [coveralls-url]: https://coveralls.io/r/jshttp/mime-db?branch=master
  55. [node-image]: https://img.shields.io/node/v/mime-db.svg
  56. [node-url]: http://nodejs.org/download/