Setting up Cloudflare R2 buckets for Active Storage
07-Feb-2025 65
Rails comes with a built-in support for saving and uploading files to S3 and S3-compatible storage services in Active Storage. Here’s how to set up Cloudflare R2.To start using Cloudflare R2, select R2 Object Storage from the menu on the left navbar. If you are on free plan you’ll need to subscribe first.
Then you can click + Create bucket and give your bucket a name. Choose meaningful names for your buckets. I usually append the environment to the name.
Cloudflare will auto assign your bucket location based on your actual location and providing a hint might not work. Not great doing this on holidays.
TIP: If you are hosting in EU, you can at least choose Specify jurisdiction and force it to be within EU.
Then on the bucket page choose Settings and include the following CORS:.
Setting up Cloudflare R2 buckets for Active Storage #ruby #rubydeveloper #rubyonrails #Setting #Cloudflare #buckets #Active #Storage #active #cloudflare https://rubyonrails.ba/link/setting-up-cloudflare-r2-buckets-for-active-storage