我在使用 AWS SDK iOS v2.1.1 以编程方式启用现有存储桶的版本控制时遇到问题。错误是 -[NSNull _fastCharacterContents]: unrecognized selector sent to instance ... 。我创建错误的代码片段是通过执行 putBucketVersioning 方法产生的:
AWSS3VersioningConfiguration *conf = [AWSS3VersioningConfiguration new];
conf.status = AWSS3BucketVersioningStatusEnabled;
AWSS3PutBucketVersioningRequest *versionRequest = [AWSS3PutBucketVersioningRequest new];
versionRequest.bucket = createBucketReq.bucket;
versionRequest.versioningConfiguration = conf;
[[[AWSS3 S3ForKey:key] putBucketVersioning:versionRequest] continueWithBlock:^id(BFTask *task) {
return task;
}
我可能在创建 AWSS3PutBucketVersioningRequest 请求的过程中遗漏了一个论点,但我找不到任何可以为我指明正确方向的示例或文档。非常欢迎任何关于 Java、Cocoa 或 Swift 的建议。干杯,特隆德
更新:
根据评论,我在启用 AWSLogging verbose 后包含完整方法和错误输出。
-(BFTask*) enableVersioningOfBucketNSString*)bucket regionNSInteger) region {
[self setupCredentialsForRegion:region];
NSString *key = [NSString stringWithFormat"regionkey%li",region];
AWSS3VersioningConfiguration *conf = [AWSS3VersioningConfiguration new];
conf.status = AWSS3BucketVersioningStatusEnabled;
AWSS3PutBucketVersioningRequest *versionRequest = [AWSS3PutBucketVersioningRequest new];
versionRequest.bucket = bucket;
versionRequest.versioningConfiguration = conf;
NSLog(@"Config %@",versionRequest);
return [[[AWSS3 S3ForKey:key] putBucketVersioning:versionRequest] continueWithBlock:^id(BFTask *task) {
NSLog(@"ut bucket versioning %@ - %@", task, task.result);
return task;
}];
}
日志消息:
2015-06-06 12:09:41.822 connectS3[50137:6337899] Config <AWSS3PutBucketVersioningRequest: 0x600000082350> {
bucket = testbucket;
versioningConfiguration = "<AWSS3VersioningConfiguration: 0x600000024bc0> {\n MFADelete = 0;\n status = 1;\n}";}
2015-06-06 12:09:41.832 connectS3[50137:6337899] -[NSNull _fastCharacterContents]: unrecognized selector sent to instance 0x7fff7724c210
更新 2
下图显示了堆栈跟踪,因为当我使用断点并单步执行每个方法调用时,错误消息刚刚出现。
更新 3
我如下所述设置我的凭据。除了启用版本控制之外,这适用于我与 S3 连接的所有其他方法。
AWSStaticCredentialsProvider *credentialsProvider = [[AWSStaticCredentialsProvider alloc ]
initWithAccessKey:keychainStore[ACCESS_KEY_ID]
secretKey:keychainStore[SECRET_KEY]];
AWSServiceConfiguration *configuration = [[AWSServiceConfiguration alloc] initWithRegion:region
credentialsProvider:credentialsProvider];
/* One credential configuration for each region **/
NSString *key = [NSString stringWithFormat"regionkey%li",region];
[AWSS3 registerS3WithConfiguration:configuration forKey:key];
/* Default credentialsProvider **/
[AWSServiceManager defaultServiceManager].defaultServiceConfiguration = configuration;
感谢您的帮助!
Best Answer-推荐答案 strong>
我可以确认这是当前 AWS 移动开发工具包中的一个错误。我们将在未来的版本中修复它。感谢您的报告。
对于解决方法,您可以将以下行添加到您的 AWSS3VersioningConfiguration 代码中:
AWSS3VersioningConfiguration *conf = [AWSS3VersioningConfiguration new];
conf.status = AWSS3BucketVersioningStatusEnabled;
conf.MFADelete = AWSS3MFADeleteDisabled; // <------ Add this line
...
关于java - 以编程方式在 AWS S3 上启用版本控制,我们在Stack Overflow上找到一个类似的问题:
https://stackoverflow.com/questions/30677529/
|