How do I use the AWS SDK for .NET with Stook?
Integrate Medianova Stook Object Storage into your .NET applications using the AWS SDK for .NET.
Last updated
Was this helpful?
Integrate Medianova Stook Object Storage into your .NET applications using the AWS SDK for .NET.
Last updated
Was this helpful?
Was this helpful?
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}");
}
}
}
}