Example #1
0
 public static PutBucketResponse  create_S3_Bucket(this API_AmazonS3 amazonS3, string newBucketName)
 {
     try
     {
         var putBucketRequest = new PutBucketRequest();
         putBucketRequest.WithBucketName(newBucketName);
         return(amazonS3.S3Client.PutBucket(putBucketRequest));
     }
     catch (Exception ex)
     {
         ex.log("[API_AmazonS3]: in create_S3_Bucket()");
     }
     return(null);
 }
Example #2
0
 public void CreateBucket(string bucketName)
 {
     using (client = Amazon.AWSClientFactory.CreateAmazonS3Client(accessKeyID, secretAccessKeyID, config))
     {
         try
         {
             PutBucketRequest request = new PutBucketRequest();
             request.WithBucketName(bucketName)
             .WithBucketRegion(S3Region.EU);
             client.PutBucket(request);
         }
         catch (AmazonS3Exception amazonS3Exception)
         {
             if (amazonS3Exception.ErrorCode != null && (amazonS3Exception.ErrorCode.Equals("InvalidAccessKeyId") || amazonS3Exception.ErrorCode.Equals("InvalidSecurity")))
             {
                 //log exception - ("Please check the provided AWS Credentials.");
             }
             else
             {
                 //log exception - ("An Error, number {0}, occurred when creating a bucket with the message '{1}", amazonS3Exception.ErrorCode, amazonS3Exception.Message);
             }
         }
     }
 }