MIME.Types
A toolbelt for working with MIME types in Elixir.
This was extracted from Plug so that other projects can make use of it.
Installation
To install through Hex:
Add
mime_typesto your list of dependencies inmix.exs:def deps do
[{:mime_types, "~> 0.1.0"}]end
Add any custom types you want to your
config/config.exs:config :mime_types, custom: %{
"application/vnd.api+json" => ["json-api"]}
Usage
The MIME module has a minimal surface area:
Returns whether a MIME type is registered.
Returns the MIME type associated with a file extension.
Guesses the MIME type based on the path’s extension.
List all registered MIME types.
List all file extensions registered with MIME types.
Show the complete MIME type mapping.
MIME.Types
Additionaly, you can use MIME.Types to generate your own registry. Tack on a Map or Keyword list to supply it with extra types.
Contributing
PRs welcome and appreciated here!