Cloudflare’s R2 is finally publicly available (it took just a year, apparently). (Here’s the original announcement: Announcing Cloudflare R2 Storage: Rapid and Reliable Object Storage, minus the egress fees)
I created a bucket.
I created a token that includes: “Edit: Allow edit access of all objects and List, Write, and Delete operations of all buckets”
Here’s what I’ve tried:
DISCOURSE_USE_S3: true
DISCOURSE_S3_REGION: auto
DISCOURSE_S3_ACCESS_KEY_ID: redacted
DISCOURSE_S3_SECRET_ACCESS_KEY: redacted
DISCOURSE_S3_CDN_URL: https://pub-72eaa03782c542edbe00598fd1666be1.r2.dev
DISCOURSE_S3_BUCKET: lc-testing
DISCOURSE_S3_BACKUP_BUCKET: lc-testing/backups
DISCOURSE_BACKUP_LOCATION: s3
DISCOURSE_S3_ENDPOINT: https://cb46accbfcc3db1bdbba2bce07f8b509.r2.cloudflarestorage.com
DISCOURSE_S3_INSTALL_CORS_RULE: false
DISCOURSE_S3_CONFIGURE_TOMBSTONE_POLICY: false
FORCE_S3_UPLOADS: 1
But uploading assets fails with this:
Aws::S3::Errors::NotImplemented: Header 'x-amz-acl' with value 'public-read' not implemented
And then I remembered to make the bucket public as described at Public buckets · Cloudflare R2 docs
But it still didn’t work.
S3 API compatibility · Cloudflare R2 docs shows that x-amz-acl is unimplemented.
Glancing at the Discourse code, it isn’t obvious to me that it’s possible to make R2 work without changes to core.
After disabling uploads, backups work, so R2 appears to be a very cheap way to have S3 backups. But since I had made that bucket public, the backup was also public (if you can guess the filename), so if this does get figured out, you’ll want separate buckets for backups and uploads.
I removed this line and was able to see that it uploaded a file, and was able to access it using a custom domain as the s3_cdn_url. (And a similar edit to the s3 rake task allows assets to get uploaded.)