Exotus v0.1.0 Exotus.Metadata View Source

Handle encoding to and from the Upload-Metadata header.

Link to this section Summary

Functions

Parse header content.

Parse header content.

Link to this section Types

Specs

header() :: String.t()

Specs

t() :: %{optional(String.t() | atom()) => String.t()}

Link to this section Functions

Specs

encode(t()) :: header()

Parse header content.

Example

iex> Exotus.Metadata.encode(%{"filename" => "world_domination_plan.pdf", "is_confidential" => :empty})
"filename d29ybGRfZG9taW5hdGlvbl9wbGFuLnBkZg==,is_confidential"

Specs

parse(header()) :: {:ok, t()} | :error

Parse header content.

Example

iex> Exotus.Metadata.parse("filename d29ybGRfZG9taW5hdGlvbl9wbGFuLnBkZg==,is_confidential")
{:ok, %{"filename" => "world_domination_plan.pdf", "is_confidential" => :empty}}
iex> Exotus.Metadata.parse("filename not_encoded,is_confidential")
:error