本文介绍了AWSS3 Region / plist配置问题'服务配置为`nil`的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am facing a strange issue with AWSS3.

设置:


  • AWS Mobile HUB

  • Cognito

  • DynamoDB

  • S3

  • AWS Mobile HUB
  • Cognito
  • DynamoDB
  • S3

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

--> Cognito, Dynamo & even S3 (through cognito user data) work.

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

However I now tried to connect directly to AWS3 with the following code:"

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.'

I我正在使用从AWS Mobiel HUB下载的plist配置,并且有点惊讶它不起作用(正如所有其他组件那样)。

I am using the downloaded plist configuration from AWS Mobiel HUB and am therfore a bit surprised that it does not work (as all other components do).

任何想法可能会出现什么问题是? plist实际上包含桶ID&区域。

Any ideas what the issue might be? The plist actually contains the bucket ID & region.

推荐答案

您的info.plist需要包含S3TransferManager。

Your info.plist needs to have S3TransferManager in it.

所以, ** AWS - > S3TransferManager - >默认 - >地区 - > ... **

你可以找到一个例子

这篇关于AWSS3 Region / plist配置问题'服务配置为`nil`的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 19:38