2.1.35 • Published 2 years ago

mime-types v2.1.35

Weekly downloads
35,040,928
License
MIT
Repository
github
Last release
2 years ago

mime-types

NPM Version NPM Downloads Node.js Version Build Status Test Coverage

The ultimate javascript content-type utility.

Similar to the mime@1.x module, except:

  • No fallbacks. Instead of naively returning the first available type, mime-types simply returns false, so do var type = mime.lookup('unrecognized') || 'application/octet-stream'.
  • No new Mime() business, so you could do var lookup = require('mime-types').lookup.
  • No .define() functionality
  • Bug fixes for .lookup(path)

Otherwise, the API is compatible with mime 1.x.

Install

This is a Node.js module available through the npm registry. Installation is done using the npm install command:

$ npm install mime-types

Adding Types

All mime types are based on mime-db, so open a PR there if you'd like to add mime types.

API

var mime = require('mime-types')

All functions return false if input is invalid or not found.

mime.lookup(path)

Lookup the content-type associated with a file.

mime.lookup('json') // 'application/json'
mime.lookup('.md') // 'text/markdown'
mime.lookup('file.html') // 'text/html'
mime.lookup('folder/file.js') // 'application/javascript'
mime.lookup('folder/.htaccess') // false

mime.lookup('cats') // false

mime.contentType(type)

Create a full content-type header given a content-type or extension. When given an extension, mime.lookup is used to get the matching content-type, otherwise the given content-type is used. Then if the content-type does not already have a charset parameter, mime.charset is used to get the default charset and add to the returned content-type.

mime.contentType('markdown') // 'text/x-markdown; charset=utf-8'
mime.contentType('file.json') // 'application/json; charset=utf-8'
mime.contentType('text/html') // 'text/html; charset=utf-8'
mime.contentType('text/html; charset=iso-8859-1') // 'text/html; charset=iso-8859-1'

// from a full path
mime.contentType(path.extname('/path/to/file.json')) // 'application/json; charset=utf-8'

mime.extension(type)

Get the default extension for a content-type.

mime.extension('application/octet-stream') // 'bin'

mime.charset(type)

Lookup the implied default charset of a content-type.

mime.charset('text/markdown') // 'UTF-8'

var type = mime.typesextension

A map of content-types by extension.

extensions... = mime.extensionstype

A map of extensions by content-type.

License

MIT

form-datarequestsendacceptsexpresstype-iswebpackwebpack-dev-middlewareserve-indexurl-loader@cypress/request@xdn/core@xdn/cliweb3stash-testvk-libwebpcssfixfree-minfhgushdhsdhfdhsgfhdlllllehseog_seog_xx@strapi/strapi@ndcb/server@zhengxs/bottle@savaleukhin/s3-static-assets@savaleukhin/aws-s3@wap/cli@iart/strapi-plugin-upload@zkmpc/phase2cli@moneylion/s3-deployarchetype-libraryaurora-router@directus-asolole/api@functionalities/mediakit@edgio/core@edgio/clicommit-cz-fixcozy-uicomponennentt@innovorder/serverless-resize-bucket-images@salto-io/salesforce-adapter@theia/mini-browser@redwoodjs/prerender@layer0/core@layer0/clieasy-select-rn@navetacandra/wa-bot@epiijs/portalricochet-jschinjowwchinjowvuedragdropuploadimagesdripple-filemanfeathers-advance-hookreact-native-bluetooth2k8-healthcheckskilli8n-react-native-fast-imagemoonpay-apiextensible-node-server@yanneves/serve-handlermasterodin-cloud-sdk-core@raulcalvo/gdrive-wrapperskdjfjlskdfjrn-send-smsrsn-node-coremajsoul-serverrectified-ioctoda-google-apidomain-auth-uispecify-importsbabel-specify-imports@lrfmedia/lrfmedia_cli@icanpm/api-masterpaperbits-demo@domain-group/fe-co-auth-ui-core@albertronics/advanced-vuetifyyoukuohao-filesyoukuohao-gatewayappup-componentsappup-components-dynamicwegdigital-cli@arisageha/react-lazyload@arisageha/react-lazyload-fix@davalapar/request@sprout2000/png2icnsiqo2-api@crmdevs/utils-v2presenti@skhon/hong-corerangewell-dataprovider@cashremit/cr-streamline-iconstsdev-serverfa-nodejsfoxart@lottojs/lottojsthemes-managerrecime-bot-engineilottie@zrthxn/gmailerblocks4node
2.1.35

2 years ago

2.1.34

2 years ago

2.1.33

3 years ago

2.1.32

3 years ago

2.1.31

3 years ago

2.1.30

3 years ago

2.1.29

3 years ago

2.1.28

3 years ago

2.1.27

4 years ago

2.1.26

4 years ago

2.1.25

4 years ago

2.1.24

5 years ago

2.1.23

5 years ago

2.1.22

5 years ago

2.1.21

6 years ago

2.1.20

6 years ago

2.1.19

6 years ago

2.1.18

6 years ago

2.1.17

7 years ago

2.1.16

7 years ago

2.1.15

7 years ago

2.1.14

7 years ago

2.1.13

7 years ago

2.1.12

8 years ago

2.1.11

8 years ago

2.1.10

8 years ago

2.1.9

8 years ago

2.1.8

8 years ago

2.1.7

9 years ago

2.1.6

9 years ago

2.1.5

9 years ago

2.1.4

9 years ago

2.1.3

9 years ago

2.1.2

9 years ago

2.1.1

9 years ago

2.1.0

9 years ago

2.0.14

9 years ago

2.0.13

9 years ago

2.0.12

9 years ago

2.0.11

9 years ago

2.0.10

9 years ago

2.0.9

9 years ago

2.0.8

9 years ago

2.0.7

9 years ago

2.0.6

9 years ago

2.0.5

9 years ago

2.0.4

9 years ago

2.0.3

9 years ago

2.0.2

10 years ago

2.0.1

10 years ago

2.0.0

10 years ago

1.0.2

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago

0.1.0

10 years ago