Skip to content

Enable Cloudflare R2 for News Image and File Uploads #486

Description

@leesheppard

Description

The application currently stores uploaded files using local disk storage. A Cloudflare R2 storage service⁠ instance has already been provisioned and configured in the application, with credentials stored and an initial setup commit available:

R2 setup commit (6397fdd)⁠

We now need to switch production file uploads to use Cloudflare R2 instead of local storage, with the immediate priority being blog post uploads performed by admin users.

Scope

Production Storage Configuration

  • Enable the existing Cloudflare R2 configuration in production.
  • Uncomment and verify the existing Active Storage configuration and credentials.
  • Ensure production environments use R2 as the Active Storage service instead of local disk storage.
  • Confirm uploads and downloads function correctly from R2.

Blog Uploads

  • Verify all blog-related file attachments (images and uploaded files) are persisted to R2.
  • Update any form implementations if required to ensure uploads are handled through Active Storage and stored remotely.
  • Ensure uploaded assets continue to render correctly in blog posts after migration.

Out of Scope

  • Migration of existing locally stored files to R2.
  • Refactoring other upload flows outside of production configuration and blog uploads (unless required to support the global Active Storage change).

Technical Notes

  • R2 credentials and configuration already exist in the application.
  • Reference implementation:
    6397fdd
  • Prefer using Active Storage’s S3-compatible adapter configuration for Cloudflare R2.
  • Validate generated URLs and attachment access in production.

Acceptance Criteria

Production Configuration

  • Production environment uses Cloudflare R2 as the Active Storage service.
  • New uploads are no longer written to local disk storage in production.
  • Uploading and retrieving files from R2 works without errors.

Blog Functionality

  • An Admin user can create a new blog post and upload images.
  • An Admin user can attach files to a blog post.
  • Uploaded images and files are stored in the Cloudflare R2 bucket.
  • Uploaded assets display and download correctly from the blog post.
  • Existing blog authoring workflow remains unchanged from the user’s perspective.

Verification

  • Confirm newly uploaded objects are visible in the R2 bucket after publishing a blog post.
  • Add or update automated tests where practical to verify Active Storage is configured to use the production service.

Definition of Done

All newly uploaded blog images and files in production are stored and served from Cloudflare R2 instead of local storage, with no regressions to the blog publishing workflow.

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    Status
    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions