Use Cloudflare R2 with Active Storage
Rails
ActiveStorage
# ... cloudflare_r2: access_key_id: YOUR_KEY secret_access_key: YOUR_SECRET
# config/storage.yml
# ..cloudflare: service: S3 endpoint: https:/you-will-fild-this-url-in-bucket-settings-bucket-details.cloudflarestorage.com access_key_id: <%= Rails.application.credentials.dig(:cloudflare_r2, :access_key_id) %> secret_access_key: <%= Rails.application.credentials.dig(:cloudflare_r2, :secret_access_key) %> region: auto bucket: name_of_my_bucket
Direct upload
in Cloudflare UI load CORS setting
[ { "AllowedOrigins": [ "localhost:3000" ], "AllowedMethods": [ "PUT" ], "AllowedHeaders": [ "*" ], "ExposeHeaders": [ "Origin", "Content-Type", "Content-MD5", "Content-Disposition" ], "MaxAgeSeconds": 3600 } ]
I have suspisoiom
[ { "AllowedOrigins": [ "http://localhost:3006", "https://myproductionapp.com" ], "AllowedMethods": [ "PUT", "GET", "HEAD" ], "AllowedHeaders": [ "Origin", "Content-Type", "Content-MD5", "Content-Disposition" ], "ExposeHeaders": [ "ETag" ], "MaxAgeSeconds": 3600 } ]