Skip to content

Conversation

jonodrew
Copy link
Contributor

@jonodrew jonodrew commented Jul 19, 2025

This is a longer-term plan, but evidences that it is low-complexity to move to S3 for image storage.

Before this is merged, we have to:

  • create an S3 bucket
  • create an IAM role with S3 access
  • download the credentials for that role
  • set them in the production environment

@jonodrew
Copy link
Contributor Author

If we implement this:

  • all admins will need to re-upload sponsor logos
  • we will need an AWS account with an IAM role to access the bucket

@jonodrew
Copy link
Contributor Author

Getting the existing logos might be tricky. If I try to

import requests

requests.get("https://assets.codebar.io/b/uploads/sponsor/avatar/931/logo.png")

I get a 522 error

@jonodrew
Copy link
Contributor Author

Screenshot, just to show it's working:
image

@jonodrew jonodrew force-pushed the aws-s3 branch 2 times, most recently from 804fea0 to 648635d Compare July 29, 2025 17:16
@jonodrew
Copy link
Contributor Author

Remove the FTP gem

# Override the directory where uploaded files will be stored.
# This is a sensible default for uploaders that are meant to be mounted:
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
"uploads/#{model.class.to_s.underscore}/#{model.id}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jonodrew I don't really mind either way but any reason we removed the mounted_as from the directory?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't sure whether it was something unique to SFTP, and the examples I found didn't have it. I'm also indifferent and happy to leave it in - I suspect it'll just end up as a slightly longer path.

It felt extraneous, but I can leave it if you prefer?

@@ -14,5 +14,15 @@
password: ENV['UPLOADER_PASSW'],
port: 22
}
elsif Rails.env.staging?
config.storage = :aws
config.aws_bucket = ENV.fetch('S3_BUCKET_NAME', 'codebar-logos')
Copy link
Contributor

@matyikriszta matyikriszta Jul 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jonodrew this is a small detail but can we rename this to sponsor-logos? codebar-logos make it sounds like it's our own logos. Also, will the config have to be updated for the products env above on line 6 and below?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is different in my most recent push because I realised I'd added more complexity where I didn't need it (I assumed we deployed simultaneously to all envs). I'm happy to rename the bucket!

@jonodrew jonodrew force-pushed the aws-s3 branch 2 times, most recently from dac1297 to e6db8e0 Compare July 29, 2025 20:06
@jonodrew jonodrew closed this Jul 29, 2025
@jonodrew jonodrew mentioned this pull request Jul 29, 2025
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants