-
-
Notifications
You must be signed in to change notification settings - Fork 72
Cloudflare R2 Storage
In order to use Cloudflare R2 storage you need to reference 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.
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);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.
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.
- In file upload requests,
DisablePayloadSigningis set to true because R2 does not support "Streaming Signature V4". - In file upload requests,
PutObjectAsyncSDK API used instead ofTransferUtility
Native operations are exposed via IAwsS3BlobStorageNativeOperations interface.