我正在使用AWS iOS框架并列出了所有我的S3存储桶。当我试图找出S3桶的区域时,我得到了区域值,但对于区域“eu-west-1”,它引发区域字符串无效的异常。AWS iOS S3异常:无效的区域字符串
下面是示例代码:
@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”地区的新斗,只是为了验证你是否得到了同样的错误?那么“欧盟”(这是欧盟西部1的有效别名)呢?我只是好奇,因为AWS甚至在S3文档中将“eu-west-1”列为有效值。 – Viccari 2012-02-17 14:51:00
据我所知,EU是一个有效的值,我通过了AWS REST API,并且知道sdk也使用了相同的REST API。在API中,他们提到欧盟是有效的价值,但在我的情况下,我得到欧盟西部1 – 2012-02-20 04:21:40
根据文件,两者都是有效的:“有效值:欧盟|欧盟西部1 |我们西1 | | us-west-2 | ap-southeast-1 | ap-northeast-1 | sa-east-1 |空字符串(用于美国经典地区)“(来自[API](http://docs.amazonwebservices。 com/AmazonS3/latest/API/RESTBucketPUT.html)) – Viccari 2012-02-20 11:27:05