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