Bucket name is added to the storage path in digitaolcean space

Please i’m having issue with the file uploaded on the digitalocean space. The bucket bucket name is included in the key of the file stored.

ex_aws 2.0
ex_aws 2.0

Please see a sample response
{:ok, %{ body: "<?xml version=\"1.0\" encoding=\"UTF-8\"?><CompleteMultipartUploadResult xmlns=\"http://s3.amazonaws.com/doc/2006-03-01/\"><Location>afribary-test.ams3.digitaloceanspaces.com</Location><Bucket>afribary-test</Bucket><Key>afribary-test/enterprise/spentary/logo-spentary-1526017375612733000.jpg</Key><ETag>32458d84455d0feda12a654fd41cff3a-1</ETag></CompleteMultipartUploadResult>", headers: [ {"x-amz-request-id", "tx00000000000000100a6d8-005af52d63-4b4052-ams3a"}, {"Content-Type", "application/xml"}, {"Content-Length", "370"}, {"Date", "Fri, 11 May 2018 05:42:59 GMT"}, {"Strict-Transport-Security", "max-age=15552000; includeSubDomains; preload"} ], status_code: 200 }}

I want to be able to access the file without /bucket-name:

but i got this
def upload(filename, space_path_without_bucket_name) do
    |> ExAws.S3.Upload.stream_file()
    |> ExAws.S3.upload(@bucket, space_path_without_bucket_name)
    |> ExAws.request()

Why are you using ex_aws for digitalocean?

I was told it also works for digitalocean and more so there is no elixir-client i could use to easily communicate with digitalocean spaces.

Please do you know of any better approach?

I’d just use an http client like HTTPoison and create a wrapper around digital ocean’s http API myself only for the endpoints that I use.

The document states that DigitalOcean Spaces is AWS Compatible. A colleague was able to upload to the object store successfully without this issue using the php/laravel sdk.

So i’m wondering why this happening with elixir sdk.



How are you configuring ExAws?

Ah on the github issue you have:

host: "afribary-test.ams3.digitaloceanspaces.com",

Don’t include the bucket in the hostname, instead do host: "ams3.digitaloceanspaces.com",


Awesome! Thank you so much.

This solved it! I’m so grateful!

1 Like