Skip to content

R2 Storage Plugin (PeachStateTechnologies.Cms.Plugins.Storage.R2)

Swaps Cofoundry's default file storage implementation for one backed by Cloudflare R2, using the AWS S3 SDK against R2's S3-compatible API.

What it does

R2StorageDependencyRegistration overrides Cofoundry's IFileStoreService with R2FileStoreService, registered as a singleton (it wraps a long-lived AmazonS3Client, which owns a pooled HTTP connection and is designed to be reused rather than constructed per-call). Once installed, every file Cofoundry stores (image assets, documents, etc.) goes to the configured R2 bucket instead of local disk/wherever the default implementation writes to.

Installing it

Reference the plugin and call AddCofoundry(...) as normal (see the developer docs overview) — no manual registration is required.

Configuration

Required — bound from the Cofoundry:Plugins:R2Storage section:

jsonc
{
  "Cofoundry": {
    "Plugins": {
      "R2Storage": {
        "ServiceUrl": "https://<accountid>.r2.cloudflarestorage.com",
        "AccessKeyId": "<R2 API token access key id>",
        "SecretAccessKey": "<R2 API token secret access key>",
        "BucketName": "<bucket name>"
      }
    }
  }
}

All four fields are required (see R2StorageSettings) — set them via environment variables or a secrets manager in production rather than committing them to appsettings.json. Generate the access key/secret from an R2 API token scoped to the target bucket in the Cloudflare dashboard.

PeachGrove CMS Documentation