Skip to content

Media - Setup Cloudflare R2

Introduction

Cloudflare R2 is a storage solution that offers S3-compatible API with no egress fees, making it a cost-effective alternative to traditional cloud storage services. Botble CMS supports Cloudflare R2 as a media storage driver, allowing you to store your media files in Cloudflare's global network.

Configuration

In the admin panel, go to Settings -> Media to configure Cloudflare R2 for storage.

  1. Select r2 as the driver
  2. Enter your Cloudflare R2 credentials and settings

Cloudflare R2 settings

Required Settings

SettingDescriptionExample
Access Key IDYour Cloudflare R2 Access Key IDa56438098e18dc7444bxxxx
Secret KeyYour Cloudflare R2 Secret Key3e63ead6a418e3b78eca46ddfe82595cd12583071bxxxxx
BucketThe name of your R2 bucketmybucket
URLThe public URL for your buckethttps://pub-f70218cc331a40689xxx.r2.dev
EndpointThe R2 API endpointhttps://xxx.r2.cloudflarestorage.com
Use Path Style EndpointWhether to use path-style endpoint accessYes (recommended for R2)

Getting Access Key ID and Secret Key

  1. Log in to your Cloudflare dashboard

  2. Navigate to R2 from the sidebar

  3. Go to Manage API Tokens

    Cloudflare R2 settings

  4. Create a new User API token with appropriate permissions

    Cloudflare R2 settings

    Cloudflare R2 settings

  5. You will receive an Access Key ID and Secret Key

    Cloudflare R2 settings

Creating a Bucket

  1. In your Cloudflare dashboard, go to R2
  2. Click on Create bucket
  3. Enter a name for your bucket
  4. Choose your settings (public or private access)
  5. Click Create bucket

Setting Up Public Access

For media files to be publicly accessible:

  1. Go to your bucket settings
  2. Navigate to the Public Access tab
  3. Enable public access for your bucket
  4. You can create a custom domain or use the default R2 domain

Troubleshooting

SignatureDoesNotMatch Error

If you encounter a SignatureDoesNotMatch error like:

SignatureDoesNotMatch: The request signature we calculated does not match the signature you provided. Check your secret access key and signing method.

This usually indicates one of the following issues:

  1. Incorrect Secret Key: Double-check your Secret Key for any typos or extra spaces
  2. Clock Synchronization: Ensure your server's clock is synchronized correctly
  3. Path Style Endpoint: Try toggling the "Use Path Style Endpoint" setting
  4. Region Setting: For Cloudflare R2, the region should always be set to auto (this is handled automatically by the CMS)

Access Denied Errors

If you receive Access Denied errors:

  1. Verify that your API token has the correct permissions for the bucket
  2. Check that the bucket name is correct and exists in your Cloudflare account
  3. Ensure that the bucket policy allows the operations you're trying to perform

Video Tutorial

Watch this video for a step-by-step guide on setting up Cloudflare R2 with Botble CMS: