i have created a folder on Amazon S3 bucket named as 'test' using following code
var bucketName = ConfigurationManager.AppSettings["bucketName"].ToString();
var AccessKey = ConfigurationManager.AppSettings["AccessKey"].ToString();
var SecretAccessKey = ConfigurationManager.AppSettings["SecretAccessKey"].ToString();
IAmazonS3 client = new AmazonS3Client(AccessKey, SecretAccessKey, RegionEndpoint.USWest2);
//Create folder with company name
var folderKey = "test"+ "/";
PutObjectRequest request = new PutObjectRequest();
request.BucketName = bucketName;
request.StorageClass = S3StorageClass.Standard;
request.ServerSideEncryptionMethod = ServerSideEncryptionMethod.None;
request.Key = folderKey;
request.ContentBody = string.Empty;
PutObjectResponse response = client.PutObject(request);
Now I want to check whether it is exist there or not..
Found some solution here on link but i need solution in C#
I would suggest to use AWSSDK.S3 NuGet package. This way you can create a AmazonS3Client and Get a list of buckets by calling var bucketsResponse = await client.ListBucketsAsync()
then you can do if (bucketsResponse.Buckets.Any(x => x.BucketName == "test"))
to check if your 'test' bucket exists.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.