Created
December 7, 2018 17:44
-
-
Save amr-swalha/eb85a1a9df6c8285d14f5872d2bb8a6a to your computer and use it in GitHub Desktop.
The code to create a bucket
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| static void CreateABucket() | |
| { | |
| try | |
| { | |
| PutBucketRequest request = new PutBucketRequest(); | |
| request.BucketName = bucketName; | |
| client.PutBucket(request); | |
| } | |
| catch (AmazonS3Exception amazonS3Exception) | |
| { | |
| if (amazonS3Exception.ErrorCode != null && (amazonS3Exception.ErrorCode.Equals("InvalidAccessKeyId") || amazonS3Exception.ErrorCode.Equals("InvalidSecurity"))) | |
| { | |
| Console.WriteLine("Please check the provided AWS Credentials."); | |
| Console.WriteLine("If you haven't signed up for Amazon S3, please visit http://aws.amazon.com/s3"); | |
| } | |
| else | |
| { | |
| Console.WriteLine("An Error, number {0}, occurred when creating a bucket with the message '{1}", amazonS3Exception.ErrorCode, amazonS3Exception.Message); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment