mimex [![Build Status]][build-link] [![Hex Version]][version-link] ![License]
MIME type utilities for Elixir.
Installation
Add the following to your mix.exs file:
defp deps do
[{"mimex", "~> 0.1.0}"]
endUsage
-
Install the library by adding it to your
mix.exs. - Call the functions when you need it.
- There is no step three.
API reference
Mimex provides the following functions:
MIME.mime_type/1— get the MIME type from the file extension.MIME.extension/1— get the first extension for a MIME type.MIME.extensions/1— get the list of extensions for a MIME type.
The above functions return {:ok, result} on success and {:error, reason} on
error. We also provide throwing versions:
MIME.mime_type!/1MIME.extension!/1MIME.extensions!/1
These either return the result on success or throw an ArgumentError with
reason as the message on failure.
When asking for the MIME type, it doesn't matter whether your extension is upper or lowercase, or whether it has a "." or not. When asking for an extension, we always return the lowercase variant with a period.
[Build Status]:https://travic-ci.org/hex-sh/mimex.svg?branch=master [Hex Version]:https://img.shields.io/hexpm/v/mimex.svg?label=hex%20version [License]:https://img.shields.io/hexpm/l/mimex.svg [build-link]:https://travis-ci.org/hex-sh/mimex [version-link]:https://hex.pm/packages/mimex