2012-02-17 100 views
0

我正在使用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); 

} 
+0

您是否尝试过,比如,创造“欧盟 - 西-1”地区的新斗,只是为了验证你是否得到了同样的错误?那么“欧盟”(这是欧盟西部1的有效别名)呢?我只是好奇,因为AWS甚至在S3文档中将“eu-west-1”列为有效值。 – Viccari 2012-02-17 14:51:00

+0

据我所知,EU是一个有效的值,我通过了AWS REST API,并且知道sdk也使用了相同的REST API。在API中,他们提到欧盟是有效的价值,但在我的情况下,我得到欧盟西部1 – 2012-02-20 04:21:40

+0

根据文件,两者都是有效的:“有效值:欧盟|欧盟西部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

回答

1

我是AWS SDK适用于iOS的维护者之一。我们已经修复了SDK中的一个错误,它没有正确处理某些区域字符串,尤其是“eu-west-1”区域字符串。

如果您升级到AWS SDK for iOS版本1.4.3或更高版本,则不应再有问题。

v1.4.3 Release Notes

S3Region.m

+0

我在2.3.0版本中遇到问题aslo – 2016-02-25 07:51:49

+0

@Sandesh请在GitHub存储库或论坛上打开一个问题,并且有人可以进一步提供帮助。 – 2016-03-02 17:23:10