Skip to content

Cloudflare R2 Storage

Robin Rodricks edited this page Jul 15, 2026 · 3 revisions

In order to use Cloudflare R2 storage you need to reference the FluentStorage.AWS package first. The provider wraps around the standard AWS SDK.

Connect to Cloudflare R2

You can use the CloudflareR2Storage factory class 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".

IStore store = CloudflareR2Storage.FromCredentials(
    accessKeyId, secretAccessKey, bucketName, cloudflareAccountId);

Connect using Connection Strings

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

AwsS3Storage.Use();

Then construct using the following format:

IStore store = StorageFactory.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.

Perform storage operations

Use our simple polycloud API to perform file and object manipulation operations.

Special features for R2

  • 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

Call the IStore.GetClient() method to return the native SDK client and perform any native operations.

Clone this wiki locally