AWS iOS S3异常:无效的区域字符串

时间:2012-02-17 09:12:52

标签: ios amazon-s3

我正在使用AWS iOS框架并列出我的所有S3存储桶。当我试图找出我的S3桶的区域时,我得到区域值,但是对于区域“eu-west-1”,它会抛出区域字符串无效的异常。

以下是示例代码:

@try {
    NSLog(@"\nViewWillappear");
    NSLog(@"---------------------------------List Buckets-------------------------");

    AmazonS3Client *s3 = [AmazonClientManager s3]; 
    NSArray *bucketNames = [s3 listBuckets];

    for(int i=0;i<[bucketNames count];i++)
    {
    S3Bucket *bucket=[bucketNames objectAtIndex:i];


 **This is the line where i get exception
 NSLog(@"region:%@",[s3 getBucketLocation:bucket.name]);**



        NSLog(@"---------------------------------List Of Objects in Bucket %@-------------------------",bucket.name);       
    NSArray *listofobjects=[[AmazonClientManager s3]listObjectsInBucket:bucket.name];   

        for(int j=0;j<[listofobjects count];j++)
        {
        S3ObjectSummary *sumarry=[listofobjects objectAtIndex:j];

        NSLog(@"\nstorage class%@  size%d",sumarry.storageClass,sumarry.size);
        }
    }



    if (buckets == nil) {
        buckets = [[NSMutableArray alloc] initWithCapacity:[bucketNames count]];
    }
    else {
        [buckets removeAllObjects];
    }

    if (bucketNames != nil) {
        for (S3Bucket *bucket in bucketNames) {
            [buckets addObject:[bucket name]];
        }
    }

    [buckets sortUsingSelector:@selector(compare:)];
}
@catch (AmazonClientException *exception) {
    NSLog(@"Exception = %@", exception);

}

1 个答案:

答案 0 :(得分:1)

我是AWS SDK for iOS的维护者之一。我们修复了SDK中没有正确处理某些区域字符串的错误,特别是“eu-west-1”区域字符串。

如果您升级到适用于iOS的AWS开发工具包的1.4.3版或更高版本,则不应再出现问题。

v1.4.3 Release Notes

S3Region.m