This guide will help you connect a .NET application to IDrive Cloud using AWS SDK. Follow the steps below and you should be able to list a bucket in IDrive Cloud via .NET application using AWS SDK.

  1. Install Visual Studio from here.

  2. Create a new Project from ‘File’ =>‘New’ =>‘Project’.

    cloud
  3. Choose a Console app (.NETFramework) project.

  4. Provide a project name, e.g. ListingBucketApplication to configure a new project for Console Application (C#).

  5. Go to 'Project' and click ‘Manage NuGet Packages’ after creating the project successfully.

    cloud
  6. Search for AWS under the 'Browse' tab. A list of all AWS SDKs will be displayed. For using the required AWS SDK with IDrive Cloud S3, you will need to install the following packages:

    cloud
    • AWSSDK.Core
    • AWSSDK.S3

  7. Verify the installed packages under the ‘Installed’ tab.

  8. Below is a sample code to list a bucket:

    Note:

    • Replace the 'program.cs' code with the below-given code.
    • Replace the 'accessKEY' and 'secretAccesskey' in the below-codes with your IDrive Cloud S3 'ACCESS KEY' and 'SECRET'.
    using Amazon;
    using Amazon.S3;
    using Amazon.S3.Model;
    using System;
    using System.IO;
    using System.Threading.Tasks;
    namespace Amazon.DocSamples.S3
    {
    	class ListBucketAPITest
    	{
    		private const string bucketName = "test-bucket";
    		private static IAmazonS3 s3Client;
    		public static void Main()
    		{
    			AmazonS3Config config = new AmazonS3Config();
    			config.ServiceURL = "https://s3.us-west-1.idrivecloud.io";
    			config.AuthenticationRegion = "us-east-1";
    			config.ForcePathStyle = true;
    			config.SignatureVersion = "2";
    			s3Client = new AmazonS3Client("accessKEY", "secretAccesskey", config);
    			ListingObjectsAsync().Wait();
    		}
    		static async Task ListingObjectsAsync()
    		{
    			try
    			{
    				ListObjectsV2Request request = new ListObjectsV2Request
    				{
    					BucketName = bucketName,
    					MaxKeys = 10
    				};
    				ListObjectsV2Response response;
    				do
    				{
    					response = await s3Client.ListObjectsV2Async(request);
    					// Process the response.
    					foreach (S3Object entry in response.S3Objects)
    					{
    						Console.WriteLine("key = {0} size = {1}",
    							entry.Key, entry.Size);
    					}
    					Console.WriteLine("Next Continuation Token: {0}", response.NextContinuationToken);
    					request.ContinuationToken = response.NextContinuationToken;
    				} while (response.IsTruncated);
    			}
    			catch (AmazonS3Exception amazonS3Exception)
    			{
    				Console.WriteLine("S3 error occurred. Exception: " + amazonS3Exception.ToString());
    				Console.ReadKey();
    			}
    			catch (Exception e)
    			{
    				Console.WriteLine("Exception: " + e.ToString());
    				Console.ReadKey();
    			}
    		}
    	}
    }
    				  


  9. Build the solution and run 'ListingBucketApplication'.



Find more sample codes here to get started.