TransferAccelerationTest.cs - AWS Code Sample

TransferAccelerationTest.cs

// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: MIT-0 using Amazon; using Amazon.S3; using Amazon.S3.Model; using System; using System.Threading.Tasks; namespace Amazon.DocSamples.S3 { class TransferAccelerationTest { private const string bucketName = "*** bucket name ***"; // Specify your bucket region (an example region is shown). private static readonly RegionEndpoint bucketRegion = RegionEndpoint.USWest2; private static IAmazonS3 s3Client; public static void Main() { s3Client = new AmazonS3Client(bucketRegion); EnableAccelerationAsync().Wait(); } static async Task EnableAccelerationAsync() { try { var putRequest = new PutBucketAccelerateConfigurationRequest { BucketName = bucketName, AccelerateConfiguration = new AccelerateConfiguration { Status = BucketAccelerateStatus.Enabled } }; await s3Client.PutBucketAccelerateConfigurationAsync(putRequest); var getRequest = new GetBucketAccelerateConfigurationRequest { BucketName = bucketName }; var response = await s3Client.GetBucketAccelerateConfigurationAsync(getRequest); Console.WriteLine("Acceleration state = '{0}' ", response.Status); } catch (AmazonS3Exception amazonS3Exception) { Console.WriteLine( "Error occurred. Message:'{0}' when setting transfer acceleration", amazonS3Exception.Message); } } } }