How do I use the AWS SDK for .NET with Wasabi?

The AWS SDK for .NET can be easily configured to work with Wasabi by simply pointing the ServiceURL to the appropriate Wasabi service URL (i.e. https://s3.wasabisys.com).   Note that 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

Steps to get started with .NET SDK:

1) Download Visual Studio

2) Download and install the AWS Toolkit for Visual Studio.  This toolkit has many code samples which will help you get started very easily

3) Below is a sample code to create a bucket:

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

namespace myApp
{
    class CreateBucketTest
    {
        private const string bucketName = "your-bucket-name";
        private static IAmazonS3 s3Client;
        public static void Main()
        {
            var endpoint = "https://s3.wasabisys.com"; //US-East-1 endpoint
            var config = new AmazonS3Config { ServiceURL = endpoint};
            var accessKey = "myAccessKey";
            var secretAccesskey = "mySecretAccessKey";
            s3Client = new AmazonS3Client(accessKey, secretAccesskey, config);
            CreateBucketAsync().Wait();
        }

        static async Task CreateBucketAsync()
        {
            try
            {
                Console.WriteLine("Trying to create a bucket");
                Console.WriteLine("S3 Client configuration: '{0}'",s3Client.Config.ServiceURL);
                if (!(await AmazonS3Util.DoesS3BucketExistAsync(s3Client, bucketName)))
                {
                    var putBucketRequest = new PutBucketRequest
                    {
                        BucketName = bucketName,
                        UseClientRegion = true
                    };

                    PutBucketResponse putBucketResponse = await s3Client.PutBucketAsync(putBucketRequest);
                    Console.WriteLine("Response returned with '{0}'",putBucketResponse.HttpStatusCode);
                }

            }
            catch (AmazonS3Exception e)
            {
                Console.WriteLine("Error encountered on server. Message:'{0}' when writing an object", e.Message);
            }
            catch (Exception e)
            {
                Console.WriteLine("Unknown encountered on server. Message:'{0}' when writing an object", e.Message);
            }
        }
    }
}

 

Note that 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

 

 

Have more questions? Submit a request