AWS SDK S3上传凭证

3
我已经按照AWS的教程 (http://docs.aws.amazon.com/mobile/sdkforios/developerguide/setup.html) 使用Swift和Xcode设置了AWS sdk iOS 9应用程序。现在我正在尝试将文件上传到S3存储桶中。
我将以下代码添加到AppDelegate.swift文件中: // 初始化Amazon Cognito凭证提供程序
let credentialsProvider = AWSCognitoCredentialsProvider(regionType:.USEast1,identityPoolId:"mypoolid")

let configuration = AWSServiceConfiguration(region:.USEast1, credentialsProvider:credentialsProvider)

AWSServiceManager.defaultServiceManager().defaultServiceConfiguration = configuration

我也在 Info.plist 文件中包含了代码片段。
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
    <key>amazonaws.com</key>
    <dict>
          <key>NSThirdPartyExceptionMinimumTLSVersion</key>
          <string>TLSv1.0</string>
          <key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
          <false/>
          <key>NSIncludesSubdomains</key>
          <true/>
    </dict>
    <key>amazonaws.com.cn</key>
    <dict>
          <key>NSThirdPartyExceptionMinimumTLSVersion</key>
          <string>TLSv1.0</string>
          <key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
          <false/>
          <key>NSIncludesSubdomains</key>
          <true/>
    </dict>
</dict>

但我收到了这个错误。如果它要求我在Info.plist中放置凭据,我该怎么做?...还是我做错了其他事情?提前感谢您的帮助。

AWSServiceInfo initWithInfoDictionary:checkRegion:] | 
Couldn't read credentials provider configurations from `Info.plist`. 
Please check your `Info.plist` if you are providing the SDK configuration values through `Info.plist`.

1
您没有通过“Info.plist”提供配置。相反,您正在使用“defaultServiceConfiguration”。您可以安全地忽略该消息。 - Yosuke
很抱歉回答得不够详细,由于声望较低,我无法进行评论。我不确定这是否适用于您的情况,但是在设置应用程序中的身份池时,我缺少了区域信息。您在应用委托中的identityPoolId也应包含它。尝试使用以下代码:let credentialsProvider = AWSCognitoCredentialsProvider(regionType: AWSRegionType.USEast1, identityPoolId:"us-east-1:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx") - valencieu
感谢您的评论...我只是打了一个例子,名为“mypoolid”。 - RafterMan680
1个回答

0

我的问题是文件无法上传到S3存储桶……凭证设置有误。在serviceConfiguration中,存储桶所在的区域不正确……一旦我更改了它,文件就上传成功了。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接