Search code examples
ruby-on-railsrails-activestorage

Rails Active Storage push to DigitalOcean Spaces


Hi I'm trying to get active storage to push to a DigitalOcean space. However, I'm finding that the push url is being changed to amazonaws.com even though I've defined the endpoint to digital ocean.

here is what I have in storage.yml

amazon:
  service: S3
  access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %>
  secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %>
  region: sfo2
  bucket: redacted_bucket_name
  endpoint: https://sfo2.digitaloceanspaces.com

When I try to upload a file, I get the following error:

Aws::Errors::NoSuchEndpointError (Encountered a `SocketError` while attempting to connect to:

  https://redacted_bucket_name.s3.sfo2.amazonaws.com/a8278561714955c23ee99

in my gemfile I have: gem 'aws-sdk-s3

I've followed the directions found here, and I'm still getting the error. Is it possible that there's a new way to do this?


Solution

  • I just set something like this up myself a few days ago. When you check the URL https://redacted_bucket_name.s3.sfo2.amazonaws.com/a8278561714955c23ee99 it's different from the actual endpoint you set up https://redacted_bucket_name.sfo2.amazonaws.com/a8278561714955c23ee99

    the error is being caused by an invalid endpoint your hitting, the s3 right before the .sfo2 is offsetting the endpoint. Did you happen to add s3 to your spaces config? check your spaces dashboard and try to get the endpoint setup properly.