Amazon AWS IOS SDK:如何在不单独命名的情况下下载存储桶中的所有文件

时间:2012-01-27 22:17:23

标签: ios download amazon-s3

我从AWS S3上传和下载文件。麻烦的是,我必须按名称指定每个文件。我希望能够下载特定存储桶(目录)中的所有文件,而无需单独命名。

我目前使用此代码:

    s3Client = [[AmazonS3Client alloc] initWithAccessKey:ACCESS_KEY withSecretKey:SECRET_KEY];              
    getObjectRequest = [[S3GetObjectRequest alloc] initWithKey:arrayName withBucket:bucketName];
    getObjectResponse = [s3Client getObject:getObjectRequest];

1 个答案:

答案 0 :(得分:2)

S3ListObjectsRequest *listObjectRequest = [[[S3ListObjectsRequest alloc] initWithName:"YourBucket"] autorelease];

S3ListObjectsResponse *listObjectResponse = [[AmazonClientManager s3] listObjects:listObjectRequest];

S3ListObjectsResult *listObjectsResults = listObjectResponse.listObjectsResult;

for (S3ObjectSummary *objectSummary in listObjectsResults.objectSummaries) {
    NSLog(@"Bucket Contents %@ " ,[objectSummary key]);
}