Skip to content

Cloudflare R2 Storage

Robin Rodricks edited this page Jul 6, 2026 · 2 revisions

In order to use Cloudflare R2 storage you need to reference NuGet package first. The provider wraps around the standard AWS SDK which is updated regularly, but adds a lot of untrivial workarounds that makes your life painless.

Connect to Cloudflare R2

You can use the CloudflareR2 method to connect to Cloudflare R2 storage servers (S3 compatible).

For cloudflareAccountId you need to enter your Cloudflare Account ID that is used to build the bucket URL like "https://{cloudflareAccountId}.r2.cloudflarestorage.com".

IBlobStorage storage = StorageFactory.Blobs.CloudflareR2(
    accessKeyId, secretAccessKey, bucketName, cloudflareAccountId);

Connection Strings

To create with a connection string, first reference the module:

StorageFactory.Modules.UseAwsStorage();

Then construct using the following format:

IBlobStorage storage = StorageFactory.Blobs.FromConnectionString("cloudflare.r2://keyId=...;key=...;bucket=...;accountId=...");

where:

  • keyId is (optional) access key ID.
  • key is (optional) secret access key.
  • bucket is bucket name.
  • accountId is your Cloudflare Account ID.

AWS CLI Profile Support

If you already have credentials in the local credentials file generated by AWS CLI, you can also use them to connect to a bucket with FluentStorage. Look here for more details.

Special features for MinIO

  • In file upload requests, DisablePayloadSigning is set to true because R2 does not support "Streaming Signature V4".
  • In file upload requests, PutObjectAsync SDK API used instead of TransferUtility

Native Operations

Native operations are exposed via IAwsS3BlobStorageNativeOperations interface.

Clone this wiki locally