gpt4 book ai didi

ios - AWSS3 区域/plist 配置问题 'The service configuration is ` nil`

转载 作者:IT王子 更新时间:2023-10-29 05:39:30 41 4
gpt4 key购买 nike

我在使用 AWSS3 时遇到了一个奇怪的问题。

设置:

  • AWS 移动中心
  • 认知
  • 动态数据库
  • 中三

--> Cognito、Dynamo 甚至 S3(通过 Cognito 用户数据)工作。

但是我现在尝试使用以下代码直接连接到 AWS3:"

let transferManager = AWSS3TransferManager.default()
let uploadRequest = AWSS3TransferManagerUploadRequest()
uploadRequest?.bucket = "XXXXXXXXXXXX"
uploadRequest?.key = "user-data/" + awsId! + "/primary_profile_picture.png"
uploadRequest?.body = imgUrl as URL

transferManager.upload(uploadRequest!).continueWith(executor: AWSExecutor.mainThread(), block: { (task:AWSTask<AnyObject>) -> Any? in

if let error = task.error as? NSError {
if error.domain == AWSS3TransferManagerErrorDomain, let code = AWSS3TransferManagerErrorType(rawValue: error.code) {
switch code {
case .cancelled, .paused:
break
default:
print("Error uploading: \(uploadRequest?.key) Error: \(error)")
}
} else {
print("Error uploading: \(uploadRequest?.key) Error: \(error)")
}
return nil
}

let uploadOutput = task.result
print("Upload complete for: \(uploadRequest?.key)")
return nil
})

我得到了错误:

AWSiOSSDK v2.5.1 [Debug] AWSInfo.m line:122 | -[AWSServiceInfo initWithInfoDictionary:checkRegion:] | Couldn't read the region configuration from Info.plist for the client. Please check your `Info.plist` if you are providing the SDK configuration values through `Info.plist`.
2017-02-20 19:29:21.748997 [2210:1152801] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'The service configuration is `nil`. You need to configure `Info.plist` or set `defaultServiceConfiguration` before using this method.'

我正在使用从 AWS Mobiel HUB 下载的 plist 配置,因此我有点惊讶它不起作用(就像所有其他组件一样)。

有什么想法可能是什么问题吗? plist 实际上包含存储桶 ID 和区域。

最佳答案

对我来说,我必须在上传之前使用以下代码配置凭据:

let credentialsProvider = AWSCognitoCredentialsProvider(regionType:.USEast1,identityPoolId:PoolID)
let configuration = AWSServiceConfiguration(region:.USEast1, credentialsProvider:credentialsProvider)

AWSServiceManager.default().defaultServiceConfiguration = configuration

其中 PoolID 是我的 Cognito 身份。我希望这对其他人有帮助。

关于ios - AWSS3 区域/plist 配置问题 'The service configuration is ` nil`,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42351925/

41 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com