AWSS3 Region / plistconfiguration问题'服务configuration是`nil`

我正面临AWSS3的一个奇怪的问题。

build立:

  • AWS移动集线器
  • Cognito
  • DynamoDB
  • S3

– > Cognito,Dynamo甚至S3(通过认知用户数据)工作。

不过,我现在尝试使用以下代码直接连接到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集线器下载的plistconfiguration,因此有点惊讶,它不起作用(所有其他组件)。

任何想法可能是什么问题? plist实际上包含了桶ID和区域。

你的info.plist需要有S3TransferManager。

所以, **AWS -> S3TransferManager -> Default -> Region -> ...**

你可以在这里find一个例子

对于我来说,在尝试上传之前,我不得不调用下面的代码:

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

其中PoolID是我的Cognito身份。 我希望这可以帮助别人。

我有相同的问题,而不是S3TransferManager你应该把DynamoDBObjectMapper

例如。

 <key>DynamoDBObjectMapper</key> <dict> <key>Default</key> <dict> <key>Region</key> <string>us-east-1</string> </dict> </dict> 

Swift 3 – Xcode 8.3.3

对于仍然有这个问题的人,我只是花了3小时来对付这个烦人的设置问题。

我在Info.plist中添加了这两个块(replace第二个块中的** **之间的variables),现在又重新工作了。

亚马逊的文档没有正确更新,我认为。 我希望这可以节省一些人一些时间。

 <key>NSAppTransportSecurity</key> <dict> <key>NSAllowsArbitraryLoads</key> <true/> <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> </dict> 

和:

 <key>AWS</key> <dict> <key>CredentialsProvider</key> <dict> <key>CognitoIdentity</key> <dict> <key>Default</key> <dict> <key>PoolId</key> <string>**YourCognitoIdentityPoolId**</string> <key>Region</key> <string>**AWSRegionUnknown**</string> </dict> </dict> </dict> <key>S3TransferManager</key> <dict> <key>Default</key> <dict> <key>Region</key> <string>**AWSRegionUnknown**</string> </dict> </dict> </dict> 

问题是,地区应该是:

 us-east-1 

代替; US_EAST_1