Skip to main content

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

The configuration steps for .NET with Stook are listed below:

  1. Download Visual Studio.

  2. Download and install the AWS Toolkit for Visual Studio.

This toolkit has a lot of code examples to help you get started easily.
Here is a sample code for creating a bucket:

CODE
using System;
using Amazon.Runtime;
using Amazon.S3;
using Amazon.S3.Model;
using Amazon.S3.Util;

namespace s3Example
{
    internal class Program
    {
        private static string bucketName = "medianovatest";
        private static string accessKey = "Enter Access Key";
        private static string secretKey = "Enter Secret Key";

        static async Task Main(string[] args)
        {
            var s3Config = new AmazonS3Config
            {
                RegionEndpoint = Amazon.RegionEndpoint.EUWest1,
                ServiceURL = "https://xxxxxxxxx.mncdn.com",
                ForcePathStyle = true
            };

            AWSCredentials awsCredentials = new BasicAWSCredentials(accessKey, secretKey);

            using (var s3Client = new AmazonS3Client(awsCredentials, s3Config))
            {
                await CreateBucket(s3Client);
            }

            Console.WriteLine("Operation completed.");
        }

        private static async Task CreateBucket(AmazonS3Client s3Client)
        {

            var createBucketRequest = new PutBucketRequest
            {
                BucketName = bucketName,
                UseClientRegion = true
            };
            try
            {
                var response = await s3Client.PutBucketAsync(createBucketRequest);
                Console.WriteLine($"Bucket creation status: {response.HttpStatusCode}");
            }
            catch (AmazonS3Exception ex)
            {
                Console.WriteLine($"{ex.Message}");
            }

        }
    }
}

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.