How do I use AWS SDK for C# with Wasabi?


AWS SDK for .NET which is a framework used for C# coding is validated for use with Wasabi and can be used with Wasabi by simply pointing the endpoint to the Wasabi service URL. To use the C#/.NET SDK with Wasabi,  execute the following steps:


1) Download JetBrains Rider IDE (you may use any IDE as per your requirements). Note that we will be using NuGet packages in this example


2) Create your project in JetBrains and navigate to NuGet as shown below in order to download and install required AWS SDK Packages




3. Type AWS in search bar to see list of all AWS SDKs, for our use case with Wasabi S3, you will need to install the following packages

  • AWSSDK.Core



4) Configure additional AWS CLI profile for Wasabi account using the Wasabi keys


NOTE: It is optional for you to use credential files to run your code but it is always a best practice to use such implementation wherein your credential keys are in a file stored on your local machine rather than being part of your actual code.

In this example we have set the profile name as "sahanip" in the "~/.aws/credentials" file.


Below is a sample code to upload objects to Wasabi:

This example discusses the use of Wasabi's us-east-1 storage region. To use other Wasabi storage regions, please use the appropriate Wasabi service URL as described in this article.  


using System;
using System.Threading.Tasks;
using Amazon.Runtime;
using Amazon.S3;
using Amazon.S3.Model;

namespace UploadToAWS
static class UploadObject
private static IAmazonS3 _s3Client;

private const string BucketName = "download-versions-bucket";

private const string ObjectName1 = "new-test-file.txt";

// updated it to take any object from desktop, just adjust the file name above
private static readonly string PathToDesktop = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);

static async Task Main()
// 1. this is necessary for the endpoint
var config = new AmazonS3Config {ServiceURL = ""};

// this will allow you to call whatever profile you have
var credentials = new StoredProfileAWSCredentials("sahanip");

// create s3 connection with credential files and config.
_s3Client = new AmazonS3Client(credentials, config);

// The method expects the full path, including the file name.
var path = $"{PathToDesktop}/{ObjectName1}";

await UploadObjectFromFileAsync(_s3Client, BucketName, ObjectName1, path);

private static async Task UploadObjectFromFileAsync(
IAmazonS3 client,
string bucketName,
string objectName,
string filePath)
var putRequest = new PutObjectRequest
BucketName = bucketName,
Key = objectName,
FilePath = filePath
putRequest.Metadata.Add("x-amz-meta-title", "someTitle");
await client.PutObjectAsync(putRequest);
catch (AmazonS3Exception e)
Console.WriteLine($"Error: {e.Message}");

Note: Please be sure to use your own BucketName and Profile Name


Build and Run your code in JetBrains, exit code 0 indicates everything worked OK



You can see the object in your bucket 





NOTE: We have also attached a download objects script example to this document


Have more questions? Submit a request