从iOS 11.4.1设备上将文件上传到AWS S3存储桶(使用AWS-IOS-SDK-2.6.24)时遇到问题。相同的代码适用于iOS 9.x.x。
主要是我收到超时错误:
Request headers:
{
"Content-Type" = "application/x-amz-json-1.1";
Host = "cognito-identity.ap-south-1.amazonaws.com";
"User-Agent" = "aws-sdk-iOS/2.6.24 iOS/11.4 en_US";
"X-Amz-Date" = 20180718T080347Z;
"X-Amz-Target" = "AWSCognitoIdentityService.GetCredentialsForIdentity";
}
2018-07-18 12:03:47:866 AWR_Vehicle_Recieving[672:656549] Request body:
{"IdentityId":"ap-south-1:999df51b-5cef-49aa-a566-369a4af76c37"}
2018-07-18 12:03:51.026657+0400 AWR_Vehicle_Recieving[672:656552] [] tcp_timers tcp[2] retransmit SYN 3
2018-07-18 12:03:51.288385+0400 AWR_Vehicle_Recieving[672:656552] [] tcp_timers tcp[3] retransmit SYN 3
2018-07-18 12:03:52.033153+0400 AWR_Vehicle_Recieving[672:656551] [] tcp_timers tcp[2] retransmit SYN 4
2018-07-18 12:03:52.290329+0400 AWR_Vehicle_Recieving[672:656551] [] tcp_timers tcp[3] retransmit SYN 4
2018-07-18 12:03:53.034734+0400 AWR_Vehicle_Recieving[672:656552] [] tcp_timers tcp[2] retransmit SYN 5
2018-07-18 12:03:53.291663+0400 AWR_Vehicle_Recieving[672:656552] [] tcp_timers tcp[3] retransmit SYN 5
2018-07-18 12:03:55.041617+0400 AWR_Vehicle_Recieving[672:656591] [] tcp_timers tcp[2] retransmit SYN 6
2018-07-18 12:03:55.298220+0400 AWR_Vehicle_Recieving[672:656591] [] tcp_timers tcp[3] retransmit SYN 6
2018-07-18 12:03:59.048019+0400 AWR_Vehicle_Recieving[672:656549] [] tcp_timers tcp[2] retransmit SYN 7
2018-07-18 12:03:59.304982+0400 AWR_Vehicle_Recieving[672:656549] [] tcp_timers tcp[3] retransmit SYN 7
2018-07-18 12:04:00.003149+0400 AWR_Vehicle_Recieving[672:656478] Status bar could not find cached time string image. Rendering in-process.
2018-07-18 12:04:07.054542+0400 AWR_Vehicle_Recieving[672:656552] [] tcp_timers tcp[2] retransmit SYN 8
2018-07-18 12:04:07.314792+0400 AWR_Vehicle_Recieving[672:656552] [] tcp_timers tcp[3] retransmit SYN 8
2018-07-18 12:04:23.061853+0400 AWR_Vehicle_Recieving[672:656552] [] tcp_timers tcp[2] retransmit SYN 9
2018-07-18 12:04:23.327710+0400 AWR_Vehicle_Recieving[672:656552] [] tcp_timers tcp[3] retransmit SYN 9
2018-07-18 12:04:48.807451+0400 AWR_Vehicle_Recieving[672:656955] Task <4E4BA101-41B3-4A33-905F-9BC082F5B45B>.<1> finished with error - code: -1001
2018-07-18 12:04:48.825138+0400 AWR_Vehicle_Recieving[672:656955] Task <4E4BA101-41B3-4A33-905F-9BC082F5B45B>.<1> HTTP load failed (error code: -999 [1:89])
2018-07-18 12:04:48:826 AWR_Vehicle_Recieving[672:656880] Session task failed with error: Error Domain=NSURLErrorDomain Code=-1001 "The request timed out." UserInfo={NSUnderlyingError=0x1c084dda0 {Error Domain=kCFErrorDomainCFNetwork Code=-1001 "(null)" UserInfo={_kCFStreamErrorCodeKey=-2102, _kCFStreamErrorDomainKey=4}}, NSErrorFailingURLStringKey=https://cognito-identity.ap-south-1.amazonaws.com/, NSErrorFailingURLKey=https://cognito-identity.ap-south-1.amazonaws.com/, _kCFStreamErrorDomainKey=4, _kCFStreamErrorCodeKey=-2102, NSLocalizedDescription=The request timed out.}
我正在关注AWS文档,仅从AWS文档中收集了所有必需的详细信息。
我已经配置了 info.plist ,并且还将 awrconfiguration.json 添加到了我的项目中。
我已经在我的AppDelegate类中提到了凭据:
AWSCognitoCredentialsProvider *credentialsProvider = [[AWSCognitoCredentialsProvider alloc]
initWithRegionType:AWSRegionAPSouth1
identityPoolId:@"ap-south-1:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx”];
AWSServiceConfiguration *configuration = [[AWSServiceConfiguration alloc] initWithRegion:AWSRegionAPSouth1
credentialsProvider:credentialsProvider];
[AWSServiceManager defaultServiceManager].defaultServiceConfiguration = configuration;
我无法理解我在这里做错了什么,因为代码在旧版iOS中可以正常工作。
我的另一个问题是:如果我们确实需要在AppDelegate类中提供凭据,那么为什么我们需要配置info.plist或为什么需要将awsconfiguration.json文件复制到我们的项目中。在不定义AppDelegate.m文件中的凭据的情况下,以什么方式从info.plist读取凭据或以编程方式读取awsconfiguration文件的方法是什么?
答案 0 :(得分:0)
这是部分答案。
嗨,
首先,消除混乱。您只需要一个:
awsconfiguration.json
Info.plist
第二,要从awsconfiguration.json
-或-Info.plist
访问配置,您可以构造:
AWSS3TransferUtility *transferUtility = [AWSS3TransferUtility defaultS3TransferUtility];
在我进一步调试时,您能否仅尝试基于代码的方法并在此处回复?