View Source S3 (S3 v0.1.0)
Small S3-compatible API request builder and stuff
Summary
Functions
Builds URI, headers, body triplet to be used with HTTP clients.
Returns a presigned URL
Calculates V4 signature
Decodes XML binaries and encodes term to XML iodata.
Types
@type option() :: {:access_key_id, String.t()} | {:secret_access_key, String.t()} | {:url, URI.t() | :uri_string.uri_string() | :uri_string.uri_map()} | {:host, String.t()} | {:region, String.t()} | {:method, :get | :post | :head | :patch | :delete | :options | :put | String.t()} | {:path, String.t()} | {:query, Enumerable.t()} | {:headers, headers()} | {:body, iodata() | {:stream, Enumerable.t()}} | {:utc_now, DateTime.t()}
@type xml_element() :: {String.t(), [xml_element() | String.t()]}
Functions
@spec build([option()]) :: {URI.t(), headers(), body :: iodata() | Enumerable.t()}
Builds URI, headers, body triplet to be used with HTTP clients.
Returns a presigned URL
Calculates V4 signature
@spec xml(binary()) :: {:ok, xml_element()} | {:error, any()}
@spec xml(xml_element()) :: iodata()
Decodes XML binaries and encodes term to XML iodata.
Examples:
iex> xml("")
** (ArgumentError) Can't detect character encoding due to lack of indata
iex> xml("<Hello></Hello>")
{:ok, {"Hello", []}}
iex> IO.iodata_to_binary(xml({"Hello", []}))
"<Hello></Hello>"
iex> xml("""
...> <book>
...>
...> <title> Learning Amazon Web Services </title>
...>
...> <author> Mark Wilkins </author>
...>
...> </book>
...> """)
{:ok, {"book", [{"title", [" Learning Amazon Web Services "]}, {"author", [" Mark Wilkins "]}]}}
iex> IO.iodata_to_binary(xml({"book", [{"title", [" Learning Amazon Web Services "]}, {"author", [" Mark Wilkins "]}]}))
"<book><title> Learning Amazon Web Services </title><author> Mark Wilkins </author></book>"
iex> xml("""
...> <?xml version="1.0" encoding="UTF-8"?>
...> <俄语 լեզու="ռուսերեն">данные</俄语>
...> """)
{:ok, {"俄语", ["данные"]}}
iex> IO.iodata_to_binary(xml({"俄语", ["данные"]}))
"<俄语>данные</俄语>"