Question

Rails 7, ActiveStorage and Spaces.

I am hitting a Aws::S3::Errors::NoSuchBucket. error when attempting to upload a file via a Rails 7.0.1 app with ruby 3.1 installed.

This is unexpected given the rails documentation and indications given here in a community tutorial https://www.digitalocean.com/community/tutorials/how-to-use-activestorage-in-rails-6-with-digitalocean-spaces

Gemfile:

gem "image_processing", "~> 1.2"
gem 'aws-sdk-s3', '~> 1.111', '>= 1.111.1'

development.rb

#  config.active_storage.service = :local
  config.active_storage.service = :digitalocean

storage.yml

test:
  service: Disk
  root: <%= Rails.root.join("tmp/storage") %>

local:
  service: Disk
  root: <%= Rails.root.join("storage") %>

digitalocean:
  service: S3
  endpoint: https://fra1.digitaloceanspaces.com
  access_key_id: <%= Rails.application.credentials.dig(:digitalocean, :access_key) %>
  secret_access_key: <%= Rails.application.credentials.dig(:digitalocean, :secret) %>
  bucket: static-images-reflektor.fra1.digitaloceanspaces.com
  region: unused

I’ve seen very old discussions about buckets on European S3 infrastruture which do not pan out - or require a 1 character change in the namespace, but that seems both dated and flaky.

The error occurs as the S3 SDK is being invoked and logged as

  TRANSACTION (6.0ms)  COMMIT
  ↳ app/controllers/articles_controller.rb:27:in `block in create'
  S3 Storage (241.5ms) Uploaded file to key: [obfuscate] (checksum: [obfuscate])
Completed 500 Internal Server Error in 355ms (ActiveRecord: 15.4ms | Allocations: 62307)



Aws::S3::Errors::NoSuchBucket (Aws::S3::Errors::NoSuchBucket):

What is wrong with the above?

Show comments

Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
January 19, 2022
Accepted Answer

Hi there,

Have you tried specifying only the name of the space itself rather than the whole FQDN:

  bucket: static-images-reflektor

Let me know how this goes. Best, Bobby

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel