0

从 iOS 11.4.1 设备上传 AWS S3 存储桶(使用 AWS-IOS-SDK-2.6.24)上的文件时遇到问题。相同的代码适用于 iOS 9.xx

大多数情况下我收到超时错误:

    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 文件复制到我们的项目中。从 info.plist 读取凭证或以编程方式读取 awsconfiguration 文件的方法是什么,而不在 AppDelegate.m 文件中定义凭证?

4

1 回答 1

0

这是部分答案。

你好,

首先,要消除混乱。你只需要一个:

  • awsconfiguration.json
  • Info.plist
  • AppDelegate(或其他地方)中基于代码的凭据

其次,要从 - 或awsconfiguration.json-访问配置,Info.plist您可以构造:

AWSS3TransferUtility *transferUtility = [AWSS3TransferUtility defaultS3TransferUtility];

您可以只尝试基于代码的方法并在我进一步调试时在这里回复吗?

于 2018-07-24T19:08:52.900 回答