stavro / arc

:paperclip: Flexible file upload and attachment library for Elixir
1.16k stars 210 forks source link

Can't delete object stored in digitalocean spaces #252

Closed papakay closed 6 years ago

papakay commented 6 years ago

I tried deleting the object stored but it was not successful.

arc 0.8.0 arc_ecto 0.8.0

Please see my code below

library = Stack.get_library_by!(:username, username)
path = Enterprise.Arc.Logo.url({library.logo, library})
[path | _] = String.split(path, "?")

Enterprise.Arc.Logo.delete({path, library})
stavro commented 6 years ago

This library does not integrate with Digital Ocean. If you are using a DO package, please post this issue there.

andreapavoni commented 6 years ago

@papakay @stavro this config is working for me:

config :arc,
  storage: Arc.Storage.S3,
  bucket: System.get_env("AWS_S3_BUCKET"),
  virtual_host: false,
  asset_host: "https://<YOUR_DO_HOST>.<REGION>.digitaloceanspaces.com/#{System.get_env("AWS_S3_BUCKET")}"

config :ex_aws,
  access_key_id: System.get_env("AWS_S3_ACCESS_KEY_ID"),
  secret_access_key: System.get_env("AWS_S3_SECRET_ACCESS_KEY"),
  s3: [
    scheme: "https://",
    host: System.get_env("AWS_S3_HOST"),
    region: System.get_env("AWS_S3_REGION")
  ]
papakay commented 6 years ago

Thanks immensely @andreapavoni for the sample config. The issue i had was not with connection to the spaces storage but with deleting those object stored. I was able to connect and upload, however once i try to delete the files, it doesn't delete and no error is shown as well.

andreapavoni commented 6 years ago

Then I think you should check ex_aws library and/or verify how arc deletes a file. In the latter case, it might depend by how arc generates urls based on configuration values. My config helps arc to generate correct, reachable digitalocean-related urls ;-)