-
-
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 the FluentStorage.AWS package first. The provider wraps around the standard AWS SDK.
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);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.
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.
Use our simple polycloud API to perform file and object manipulation operations.
- 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
Call the IStore.GetClient() method to return the native SDK client and perform any native operations.