Reputation: 1073
I'm trying to find a aws-client for elixir that can be used with digitalocean spaces. I tried aws-elixir (since it allowed different endpoint), but I can't find a way to do S3 operations.
I ask,
Upvotes: 1
Views: 374
Reputation: 3968
aws-elixir does not support S3 unfortunately, but ExAws does. In order to use ExAws, you first need to add these dependencies in your mix.exs
file:
defp deps() do
[
{:ex_aws, "~> 2.0"},
{:ex_aws_s3, "~> 2.0"},
{:poison, "~> 3.0"},
{:hackney, "~> 1.9"},
{:sweet_xml, "~> 0.6"},
]
end
Note that both ex_aws
and ex_aws_s3
need to be added to your dependencies. hackney
is an HTTP client, poison
is for JSON parsing, and sweet_xml
is for XML parsing.
Now that you added the dependencies, next you need to configure S3 to connect to DigitalOcean spaces instead.
Type this into your config.exs file:
config :ex_aws, :s3,
%{
access_key_id: "access key",
secret_access_key: "secret key",
scheme: "https://",
host: %{"sfo2" => "your-space-name.sfo2.digitaloceanspaces.com"},
region: "sfo2"
}
"access key"
and "secret key"
need to be replaced with the actual keys you get from DigitalOcean.
Please make sure to replace "sfo2"
with the actual Spaces region you're using. And of course, put your actual space name instead of your-space-name
.
Don't forget to run mix deps.get
, and you're all set.
You can start an iex
session and verify that all is working, by running iex -S mix
, and then typing:
ExAws.S3.list_objects("bucket") |> ExAws.request!
Upvotes: 4