MagicNumber (magic_number v0.0.6) View Source
The module to determine a file's type from its magic number.
Link to this section Summary
Types
A media type is a two-part identifier for file format. For example
Functions
Determine media type from its contents.
Link to this section Types
Specs
A media type is a two-part identifier for file format. For example:
{:application, :zip} # application/zip
{:image, :png} # image/png
Link to this section Functions
Specs
detect(binary()) :: {:ok, media_type()} | :error
Determine media type from its contents.
Examples
iex> MagicNumber.detect("GIF89a...")
{:ok, {:image, :gif}}
iex> MagicNumber.detect(<<>>)
:error