I am trying to change the AWS S3 bucket used by active_storage. My original entry was as follows
# config/storage.yml
amazon:
service: S3
access_key_id: <%= ENV['S3_ACCESS_KEY_ID'] %>
secret_access_key: <%= ENV['S3_SECRET_ACCESS_KEY'] %>
region: 'us-east-1'
bucket: 'us-bucket-name'
This works fine. But I want to change it to a new bucket, called aus-bucket-name
that is in the Sydney region, with region code ap-southeast-2
. So I am using
# config/storage.yml
amazon:
service: S3
access_key_id: <%= ENV['S3_ACCESS_KEY_ID'] %>
secret_access_key: <%= ENV['S3_SECRET_ACCESS_KEY'] %>
region: 'ap-southeast-2'
bucket: 'aus-bucket-name'
When I try to upload to the bucket, in the heroku server logs I see
S3 Storage (1.9ms) Generated URL for file at key: xyz (https://aus-bucket-name.s3.ap-southeast-2.amazonaws.com/...
but nothing happens, the uploading page just waits, but nothing is uploaded. I am using the direct_upload.js
progress indicator, but the file-name box does not show any activity.
If I go back to the 'us-east-1' region, then the file upload works fine, but I have a couple of extra file upload boxes when the file is loading from us-east region
so it looks like the uploads from the sydney region are still pending. How do I fix this?
It turned out the aus-bucket-name
did not have the correct CORS permissions, i.e it was different from the us-bucket-name
. When I set the CORS permissions properly, it worked fine. See this post for a description on how to set the CORS permissions for Amazon.