Linode Object Storage with .NET and C#

Linode Object Storage is now available on Frankfurt data centre [1]. It is much more affordable and easier to manage unstructured data such as content assets (images, files etc..), sophisticated and data-intensive storage challenges around artificial intelligence and machine learning.

Since it is S3-compatible object storage, we can use AWS SDK for .NET for any operations needed.

1. Create a Project

dotnet new console 

2. Add Amazon SDK

dotnet add package AWSSDK.S3 

3. Example: List the buckets

class Program
    {
        static void Main(string[] args)
        {
            string accessKey = "**";
            string secretKey = "**";

            var config = new AmazonS3Config
            {
                RegionEndpoint = RegionEndpoint.EUCentral1, // Our bucket is on eu data center
                ServiceURL = "https://eu-central-1.linodeobjects.com" 
            };
            var amazonS3Client = new AmazonS3Client(accessKey, secretKey, config);
            ListMehmetBuckets(amazonS3Client).Wait();

        }

        static async Task ListMehmetBuckets(AmazonS3Client amazonS3Client)
        {
           var listBucketResponse = await amazonS3Client.ListBucketsAsync();
            foreach (var bucket in listBucketResponse.Buckets)
            {
                Console.Out.WriteLine("bucket '" + bucket.BucketName + "' created at " + bucket.CreationDate);
            }
            if (listBucketResponse.Buckets.Count > 0)
            {
                var bucketName = listBucketResponse.Buckets[1].BucketName;
                var listObjectsResponse = await amazonS3Client.ListObjectsAsync(bucketName);
                foreach (var obj in listObjectsResponse.S3Objects)
                {
                    Console.Out.WriteLine("key = '" + obj.Key + "' | size = " + obj.Size + " | tags = '" + obj.ETag + "' | modified = " + obj.LastModified);
                }
            }

        }
    }

You need to enable Object Storage in your Linode account before all. Check Linode docs for the details.
That’s all.

[1] Linode Storage Solutions
#linode #objectstorage #amazon-s3 #amazon-sdk-net