图片未在亚马逊s3上传。我使用旧库所有上传工作正常但是对于ios 8我使用新的sdk并创建新的conginito id 现在我面临着错误。任何帮助将不胜感激 我的代码是
AWSS3TransferManagerUploadRequest *request = [[AWSS3TransferManagerUploadRequest alloc] init];
request.bucket = @"my bucket name";
request.key = @"my cognitio id";
request.body =[NSURL fileURLWithPath:path];
request.contentType = @"image/png";
[[transferManager upload:request] continueWithExecutor:[BFExecutor mainThreadExecutor]
withBlock:^id(BFTask *task) {
NSLog(@"ckmdkcd dvdsv");
if (task.error) {
if ([task.error.domain isEqualToString:AWSS3TransferManagerErrorDomain]) {
switch (task.error.code) {
case AWSS3TransferManagerErrorCancelled:
case AWSS3TransferManagerErrorPaused:
break;
default:
NSLog(@"Error: %@", task.error);
break;
}
} else {
// Unknown error.
NSLog(@"Error: %@", task.error);
}
}
if (task.result) {
AWSS3TransferManagerUploadOutput *uploadOutput = task.result;
// The file uploaded successfully.
NSLog(@"result = %@",task.result);
}
return nil;
}];
我收到了以下回复
AWSiOSSDKv2 [Error] AWSIdentityProvider.m line:185 | __51-[AWSAbstractCognitoIdentityProvider getIdentityId]_block_invoke169 | GetId failed. Error is [Error Domain=NSURLErrorDomain Code=-1003 "The operation couldn’t be completed. (NSURLErrorDomain error -1003.)" UserInfo=0x7f9b987aabf0 {NSErrorFailingURLStringKey=https://cognito-identity.(null).amazonaws.com/, NSErrorFailingURLKey=https://cognito-identity.(null).amazonaws.com/, _kCFStreamErrorDomainKey=12, _kCFStreamErrorCodeKey=8, NSUnderlyingError=0x7f9b9a839480 "The operation couldn’t be completed. (kCFErrorDomainCFNetwork error -1003.)"}]
2015-04-14 08:13:16.326 newtest[6611:172200] AWSiOSSDKv2 [Error] AWSCredentialsProvider.m line:534 | __40-[AWSCognitoCredentialsProvider refresh]_block_invoke350 | Unable to refresh. Error is [Error Domain=NSURLErrorDomain Code=-1003 "The operation couldn’t be completed. (NSURLErrorDomain error -1003.)" UserInfo=0x7f9b987aabf0 {NSErrorFailingURLStringKey=https://cognito-identity.(null).amazonaws.com/, NSErrorFailingURLKey=https://cognito-identity.(null).amazonaws.com/, _kCFStreamErrorDomainKey=12, _kCFStreamErrorCodeKey=8, NSUnderlyingError=0x7f9b9a839480 "The operation couldn’t be completed. (kCFErrorDomainCFNetwork error -1003.)"}]
2015-04-14 08:13:16.328 newtest[6611:172071] ckmdkcd dvdsv
2015-04-14 08:13:16.328 newtest[6611:172071] Error: Error Domain=NSURLErrorDomain Code=-1003 "The operation couldn’t be completed. (NSURLErrorDomain error -1003.)" UserInfo=0x7f9b987aabf0 {NSErrorFailingURLStringKey=https://cognito-identity.(null).amazonaws.com/, NSErrorFailingURLKey=https://cognito-identity.(null).amazonaws.com/, _kCFStreamErrorDomainKey=12, _kCFStreamErrorCodeKey=8, NSUnderlyingError=0x7f9b9a839480 "The operation couldn’t be completed. (kCFErrorDomainCFNetwork error -1003.)"}
我也在app delegate中设置cognitio id。
答案 0 :(得分:2)
根据您在错误中看到https://cognito-identity.(null).amazonaws.com/
的事实,这会让我相信您在创建AWSCognitoCredentialsProvider
时没有正确设置区域。请仔细检查您是否将其设置为AWSRegionUnknown
。
更新2015-04-17 :Here is the list of Region constants。您应该将其设置为您的标识池所在的区域。目前,Amazon Cognito仅适用于AWSRegionUSEast1
或AWSRegionEUWest1
。
请注意,您的身份池区域与您在应用程序中可能使用的其他AWS服务区域无关。例如,您可以使用AWSRegionUSEast1
中的标识池来访问AWSRegionSAEast1
中的资源。