FileStore.Adapters.S3 (file_store v0.2.1)

Stores files using Amazon S3.

Dependencies

To use this adapter, you'll need to install the following dependencies:

def deps do
  [
    {:ex_aws_s3, "~> 2.0"},
    {:hackney, ">= 0.0.0"},
    {:sweet_xml, ">= 0.0.0"}
  ]
end

Configuration

  • bucket - The name of your S3 bucket. This option is required.

  • base_url - The base URL that should be used for generating the public URLs to your files.

  • ex_aws - A keyword list of options that can be used to configure ExAws.

  • prefix - An optional prefix for the FileStore that acts like a parent directory. If the prefix is "images", then storing a file ("cat.jpg") in S3 with this store will have the resolved key or "images/cat.jpg". (This is most useful with use FileStore.Config modules.)

Example

iex> store = FileStore.new(
...>   adapter: FileStore.Adapters.S3,
...>   bucket: "mybucket"
...> )
%FileStore{...}

iex> FileStore.write(store, "foo", "hello world")
:ok

iex> FileStore.read(store, "foo")
{:ok, "hello world"}