Setting Up Cloudflare R2

Before you can use the Uploader Template, you need to set up your Cloudflare R2. This guide will walk you through the process. We will assume you have already set up your Cloudflare account and have a domain name managed in Cloudflare.

  1. Open Cloudflare's dashboard.
  2. Navigate to the R2 Object Storage.
    • Click on the R2 Object Storage tab in the left sidebar.
    Navigating to R2 Object Storage
  3. Create a new bucket.
    • Click on the Create Bucket button.
    Creating a new bucket
    • Enter a name for the bucket.
    • Choose a region. (We recommend choosing Automatic).
    • Choose a storage class. (We recommend choosing Standard).
    • Click on the Create Bucket button.
    Configuring the bucket
  4. Configure the bucket.
    • Click on the Settings tab.
    Opening the bucket settings tab
    • Scroll down until you see the Public Access section.
    • Click on Connect Domain.
    Public Access section
    • It is recommended to use a subdomain for the bucket. For example, cdn.example.com.
    • Click on the Continue button.
    Connecting a domain
    • Preview the DNS record that will be created. If everything looks good, click on the Connect domain button.
    Previewing the DNS record
    • Wait for the DNS record to propagate. After that, you can access your bucket using the subdomain you chose.
  5. Adding a CORS Policy.
    • Scroll down until you see the CORS Policy section.
    • Click on Add CORS Policy.
    Adding a cors policy
    • Enter the following configuration:
      [
          {
              "AllowedOrigins": [
                  "http://127.0.0.1:3000",
                  "https://example.com"
              ],
              "AllowedMethods": [
                  "GET",
                  "POST",
                  "DELETE",
                  "PUT",
                  "HEAD"
              ]
          }
      ]
      
    • The above configuration allows requests from the specified origins and methods. You can modify it according to your needs.
    • Click on the Save button.

That's it! You have successfully set up your Cloudflare R2 Object Storage. You can now use it with the Uploader Template.

Next Steps