Amazon S3 List Objects

I have this code to display objects in a folder.

var accessKey = ConfigurationManager.AppSettings["AWSAccessKey"];
            var secretKey = ConfigurationManager.AppSettings["AWSSecretKey"];

            using (AmazonS3Client s3Client = new AmazonS3Client(accessKey, secretKey, RegionEndpoint.USEast1 ))
            {
                var prefix = string.Format(@"{0}/", uniqueKey);
                ListObjectsRequest request = new ListObjectsRequest();
                request.BucketName = bucketName;
                request.Delimiter = "/";
                request.Prefix = prefix;

                do
                {
                    ListObjectsResponse response = s3Client.ListObjects(request);

This throws an exception when accessing folders:

<uri>/bucketname/profile/ // Throws and exception key not found
<uri>/bucketname/profile/profile.png // This is OK

The image was created using the following path having a READCannedACL.

<uri>/bucketname/profile//profile.png

Mistake String key was not found

Question

  • Why can't I access folders (objects)?
  • Do folders need to set individual permissions for access?

UPDATE I solved the problem

Bucket names should not have a symbol. /The client gave me the name of the bucket in this format. sample/newBut the true name of the bucket is onlysample

0
source share

No one has answered this question yet.

Source: https://habr.com/ru/post/1614613/


All Articles