我正面临着AWSS3的一个奇怪问题。
设定:
- > 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 HUB下载的plist配置,因此它有点惊讶它不起作用(正如所有其他组件那样)。
任何想法可能是什么问题? plist实际上包含桶ID和amp;区域。
答案 0 :(得分:10)
对我来说,在上传之前,我必须使用以下代码配置凭据:
let credentialsProvider = AWSCognitoCredentialsProvider(regionType:.USEast1,identityPoolId:PoolID)
let configuration = AWSServiceConfiguration(region:.USEast1, credentialsProvider:credentialsProvider)
AWSServiceManager.default().defaultServiceConfiguration = configuration
其中PoolID是我的Cognito身份。我希望这有助于其他人。
答案 1 :(得分:8)
您的info.plist需要包含S3TransferManager。
所以,-- User defined table-valued function
Create Function dbo.udf_GetSalesByCompany
(@companyName varchar(25) )
RETURNS TABLE AS
RETURN Select * from sales where Company_Name = @company1;
--Usage
SELECT * FROM dbo.udf_GetSalesByCompany('AA');
SELECT * FROM dbo.udf_GetSalesByCompany('BB');
-- Usage with params
DECLARE @company1 varchar(25)
set @company1 = 'AA';
SELECT * FROM dbo.udf_GetSalesByCompany(@company1);
set @company1 = 'BB';
SELECT * FROM dbo.udf_GetSalesByCompany(@company1);
您可以找到一个here
的示例答案 2 :(得分:2)
我有同样的问题而不是S3TransferManager你应该放置DynamoDBObjectMapper
e.g ..
<key>DynamoDBObjectMapper</key>
<dict>
<key>Default</key>
<dict>
<key>Region</key>
<string>us-east-1</string>
</dict>
</dict>
答案 3 :(得分:1)
Swift 3 - Xcode 8.3.3
对于仍然遇到这个问题的人,我只花了3个小时来对付这个烦人的设置问题。
我在Info.plist中添加了这些块(在第二个块中替换** **之间的变量),现在它再次工作。
我认为亚马逊的文档没有正确更新。我希望这可以节省一些人的时间。
<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>
答案 4 :(得分:1)
问题是,地区应该是:
us-east-1
而不是; US_EAST_1
答案 5 :(得分:0)
使用数据添加服务配置文件
如果上面标记的解决方案在某些情况下不起作用。尝试以下解决方案。
正如错误所说,服务配置文件为零。因此,我们需要添加具有以下数据的 awsconfiguration.json 文件。
{
"Version": "1.0",
"IdentityManager": {
"Default": {}
},
"CredentialsProvider": {
"CognitoIdentity": {
"Default": {
"PoolId": "REPLACE_ME",
"Region": "REPLACE_ME"
}
}
},
"S3TransferUtility": {
"Default": {
"Bucket": "REPLACE_ME",
"Region": "REPLACE_ME"
}
}
}
替换项目的bucket、region、poolId。