Amazon S3 : List Objects

蓝咒 提交于 2019-12-13 07:00:28

问题


I have this code to list objects in the 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 I access the folders :

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

Image was created using the following path having a READ CannedACL.

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

Error String key was not found

QUESTION

  1. Why i cannot access the folders (objects)?
  2. Are folders need to set permissions individually for it to be accessible?

UPDATE I solved the issue

Bucket names should not have a / character Client given me a bucket name with this format sample/new But the true bucket name is only sample

来源:https://stackoverflow.com/questions/39106395/amazon-s3-list-objects

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!