SlowpokeArc v0.2.0 SlowpokeArc View Source
Provides a storage module for Arc.
With this storage method, all images are stored locally first, then are queued to be uploaded to AWS, and after uploading is done, the local copy is deleted. Either an uploading is in progress or is already done, the returned url for the resource is always valid.
Examples
To use it, define your configured module:
defmodule MyApp.Storage do
use SlowpokeArc
end
and then you can add it to config:
config :arc, storage: MyApp.Storage
By default it uses Arc.Storage.Local
for locally saved files
and Arc.Storage.S3
for uploadings, but you can change this
behavior by providing options when using. The example above is
equivalent to the following one:
defmodule MyApp.Storage do
use SlowpokeArc,
local_storage: Arc.Storage.Local,
inet_storage: Arc.Storage.S3
end
Configuration
Configuration of storages is pretty much the same as with default arc storages:
config :arc,
storage: MyApp.Storage,
storage_dir: "/pictures_with_cats",
bucket: "<your-bucket-name>",
virtual_host: true
config :ex_aws,
access_key_id: ["<your-key-id>", :instance_role],
secret_access_key: ["<your-secret-key>", :instance_role],
region: "<your-region>"
Static
You may want to replace your Plug.Static
with the one that provides
your storage:
plug MyApp.Storage.StaticPlug,
at: "/uploads",
from: {:my_app, "uploads"}
See SlowpokeArc.StaticPlug
for more details.