Skip to content

hex-sh/mimex

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mimex

Build Status

MIME type utilities for Elixir. Get the MIME type for an extension or a list of extensions for a MIME type. Documentation is available here.

Usage

Add the following to your mix.exs file:

defp deps do
  [{:mimex, "~> 0.1.0"}]
end

Then run mix deps.get. You're now able to call the functions we provide. See the section on functions for a brief reference.

Functions

mimex provides the following functions:

  1. MIME.mime_type/1 — get the MIME type from the file extension.
  2. MIME.extension/1 — get the first extension for a MIME type.
  3. 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:

  1. MIME.mime_type!/1
  2. MIME.extension!/1
  3. MIME.extensions!/1

These either return the result on success or throw an ArgumentError with reason as the message on failure.

It doesn't matter whether you call the above functions with upper or loewrcase extensions. It also doesn't matter if the . is present or not. When you pass in a MIME type, we always return a lowercase extension with a ..

About

MIME type utilities for Elixir

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages