Amazon S3:列出对象

时间:2016-08-23 16:28:13

标签: c# amazon-web-services amazon-s3 aws-sdk

我有这段代码列出文件夹中的对象。

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);

当我访问文件夹时抛出异常:

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

使用以下具有READ CannedACL的路径创建图像。

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

错误 String key was not found

问题

  1. 为什么我无法访问文件夹(对象)?
  2. 文件夹是否需要单独设置权限才能访问?
  3. 更新 我解决了这个问题

      

    存储桶名称不应包含/个字符   客户端给了我一个格式为sample/new的存储桶名称   但真正的存储桶名称仅为sample

0 个答案:

没有答案