Debugging AWS S3 for Rails Active Storage

Rails Tech WebDev

It could be your CORS configuration for AWS S3 for Rails ActiveStorage

If you've gotten to the point where you can add an upload to Active Storage but then the items somehow disappear, it's probably your CORS configuration that's wrong. 

Credit to Mike Rogers for helping me get the right CORS settings here — 

This is what you'll need to toss into your CORS settings for your AWS bucket 

<pre>
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
    <AllowedOrigin>*</AllowedOrigin>
    <AllowedMethod>GET</AllowedMethod>
    <MaxAgeSeconds>3000</MaxAgeSeconds>
    <AllowedHeader>Authorization</AllowedHeader>
</CORSRule>
<CORSRule>
    <AllowedOrigin>*</AllowedOrigin>
    <AllowedMethod>PUT</AllowedMethod>
    <AllowedMethod>POST</AllowedMethod>
    <MaxAgeSeconds>3000</MaxAgeSeconds>
    <AllowedHeader>*</AllowedHeader>
</CORSRule>
</CORSConfiguration>
</pre>


Similar Posts

Refactoring Rails: Use REST

Just some notes / key takeaways from the course "Refactoring Rails" by the great Ben Orenstein.

WebDev Rails

Simple Full Text Search in Rails

No gems, no dependencies, no complexity. Here’s a basic full text search to use on simpler, smaller rails apps.

Rails WebDev

Refactoring Rails: Callbacks

I've abused callbacks enough to know they have limits. This post is some summarized notes on the recommendations for using callbacks effectively.

WebDev Rails

JavaScript Spread Operator

When dealing with many different objects in JavaScript, sometimes you need to compile them all down together. The spread operator is a handy function for this and more.

JavaScript QuickTip