-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
R2 how to implement in .net project? #4683
Comments
Hi, any news? |
It'll be no different to any other S3-compatible provider. Point it to your endpoint with the proper tokens (https://developers.cloudflare.com/r2/platform/s3-compatibility/tokens/) and make sure the bucket region is |
Adding onto this, you can probably use any S3 SDK (e.g. https://aws.amazon.com/sdk-for-net/). We don't yet have examples for C# libraries it looks like. https://docs.aws.amazon.com/sdk-for-net/v3/developer-guide/quick-start-s3-1-cross.html is probably a fine initial guide. Note that you probably want to customize your creds either by adjusting the shared AWS credentials file as explained on that page ( |
As an example until I finish it up & PR it to the docs: private static IAmazonS3 s3Client;
public static void Main(string[] args) {
var accessKey = "<ACCESS_KEY_ID>";
var secretKey = "<SECRET_KEY_ID>";
var credentials = new BasicAWSCredentials(accessKey, secretKey);
s3Client = new AmazonS3Client(credentials, new AmazonS3Config {
ServiceURL = "https://<ACCOUNT_ID>.r2.cloudflarestorage.com",
});
PutObject().Wait();
}
static async Task PutObject() {
var request = new PutObjectRequest {
FilePath = @ "/Users/kian/Downloads/foo.dmg",
BucketName = "sdk-example",
DisablePayloadSigning = true // required otherwise it attempts to use streaming sigv4
};
var response = await s3Client.PutObjectAsync(request)
Console.WriteLine(response.ETag);
} |
Which Cloudflare product(s) does this pertain to?
R2
Subject Matter
.Net Example
Content Location
Hi,
How to use R2 in .net project.
I cant find any document or example anywhere.
Thanks.
Additional information
No response
The text was updated successfully, but these errors were encountered: