Module mimetypes

Behaviours: gen_server.

Function Index

create/1Create a new database of extension-mimetype mappings.
dmodule/0
ext_to_mimes/1Return the set of known mimetypes of an extension.
ext_to_mimes/2Return the set of known mimetypes of an extension.
extension/1Transforms an extension to a list of mimetypes.
extensions/0Return a list of all available extensions.
extensions/1Convert mimetype to a list of extensions.
filename/1Convert a filename to a list of mimetypes.
load/2Load a set of extension-mimetype mappings.
load/3Load a set of extension-mimetype mappings.
mime_to_exts/1Return the set of known extensions of a mimetype.
mime_to_exts/2Return the set of known extensions of a mimetype.
mmodule/0
path_to_mimes/1Return the set of known mimetypes based on the extension of a path.
path_to_mimes/2Return the set of known mimetypes based on the extension of a path.
start_link/0 Starts the server.
types/0Return a list of all available mimetypes.

Function Details

create/1

create(Database::term()) -> ok

Create a new database of extension-mimetype mappings. The name 'default' is reserved.

dmodule/0

dmodule() -> any()

ext_to_mimes/1

ext_to_mimes(Extension::string() | binary()) -> [binary()]

Equivalent to ext_to_mimes(Extension, default).

Return the set of known mimetypes of an extension.

ext_to_mimes/2

ext_to_mimes(Extension::string() | binary(), Database::term()) -> [binary()]

Return the set of known mimetypes of an extension.

extension/1

extension(Extension::binary() | string()) -> [binary()]

Transforms an extension to a list of mimetypes.

Returns application/octet-stream if there is no data about given extension.

Example:

  1> mimetypes:extension("c").
  [<<"text/x-c">>]
  2> mimetypes:extension("hrl").
  [<<"application/octet-stream">>]
  3> mimetypes:extension(<<"html">>).
  [<<"text/html">>]

extensions/0

extensions() -> [binary()]

Return a list of all available extensions.

extensions/1

extensions(Types::[binary()] | binary()) -> [binary()]

Convert mimetype to a list of extensions.

Example:

  1> mimetypes:extensions([<<"text/html">>]).
  [<<"htm">>,<<"html">>]
  2> mimetypes:extensions([<<"text/html">>, <<"text/x-c">>]).
  [<<"c">>,<<"cc">>,<<"cpp">>,<<"cxx">>,<<"dic">>,<<"h">>,
   <<"hh">>,<<"htm">>,<<"html">>]

filename/1

filename(Filename::string()) -> [binary()]

Convert a filename to a list of mimetypes.

Example:

  1> mimetypes:filename("test.cpp").
  [<<"text/x-c">>]
  2> mimetypes:filename("/etc/fstab").
  ["<<application/octet-stream">>]
  3> mimetypes:filename("/etc/adduser.conf").
  [<<"text/plain">>]

load/2

load(Database::term(), Mappings::[{binary(), binary()}]) -> ok

Load a set of extension-mimetype mappings.

load/3

load(Database::term(), Mappings::[{binary(), binary()}], Timeout::infinity | integer()) -> ok

Load a set of extension-mimetype mappings.

mime_to_exts/1

mime_to_exts(MimeType::string() | binary()) -> [binary()]

Equivalent to mime_to_exts(MimeType, default).

Return the set of known extensions of a mimetype.

mime_to_exts/2

mime_to_exts(MimeType::string() | binary(), Database::term()) -> [binary()]

Return the set of known extensions of a mimetype.

mmodule/0

mmodule() -> any()

path_to_mimes/1

path_to_mimes(Path::string() | binary()) -> [binary()]

Return the set of known mimetypes based on the extension of a path.

path_to_mimes/2

path_to_mimes(Path::string() | binary(), Database::term()) -> [binary()]

Return the set of known mimetypes based on the extension of a path.

start_link/0

start_link() -> {ok, Pid} | ignore | {error, Error}

Starts the server

types/0

types() -> [binary()]

Return a list of all available mimetypes.


Generated by EDoc, Sep 13 2013, 21:19:39.