gpt4 book ai didi

ios - Amazon s3 图片上传(cognito id null)

转载 作者:行者123 更新时间:2023-11-29 10:31:01 25 4
gpt4 key购买 nike

图像未在 amazon 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.)"}

我还在应用程序委托(delegate)中设置认知 ID。

最佳答案

基于您在错误中看到 https://cognito-identity.(null).amazonaws.com/ 的事实,这会让我相信您没有正确设置区域创建 AWSCognitoCredentialsProvider 时。请仔细检查您是否没有将此设置为 AWSRegionUnknown

2015 年 4 月 17 日更新:Here is the list of Region constants .您应该将其设置为您的身份池所在的区域。目前,Amazon Cognito 仅在 AWSRegionUSEast1AWSRegionEUWest1 中可用。

请注意,您的身份池区域与您可能在应用程序中使用的其他 AWS 服务的区域无关。例如,您可以使用 AWSRegionUSEast1 中的身份池来访问 AWSRegionSAEast1 中的资源。

关于ios - Amazon s3 图片上传(cognito id null),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29631181/

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