aws-amplify / aws-sdk-ios

AWS SDK for iOS. For more information, see our web site:
https://aws-amplify.github.io/docs
Other
1.67k stars 877 forks source link

AWSS3TransferUtilityTimeoutIntervalForResource #773

Closed nick3389 closed 6 years ago

nick3389 commented 6 years ago

Will there be a future possibility to customize the AWSS3TransferUtilityTimeoutIntervalForResource static property of AWSS3TransferUtility class?

Thank you!

mutablealligator commented 6 years ago

Hi @nick3389, Thanks for reporting to us. The limit of 50 minutes is imposed by Amazon Cognito Federated Identities. The Cognito credentials need to be refreshed after every 50 minutes and this is required for the S3 operations to succeed. Hence, AWSS3TransferUtilityTimeoutIntervalForResource is a constant.

nick3389 commented 6 years ago

@kvasukib So, if I use only the AWSS3TransferUtility and not the Cognito service, am I restricted to this timeout?

mutablealligator commented 6 years ago

The AWSS3TransferUtility creates PreSigned URLs that rely on the Cognito Identity to retrieve temporary credentials. http://docs.aws.amazon.com/mobile/sdkforios/developerguide/s3transferutility.html#limitations. You can use AWSS3 class instead which is the low-level client and you will not be having this interval limit when you use it with STS (Security Token Service) or AWS Access / Secret Access Keys.

nick3389 commented 6 years ago

@kvasukib Do you mean the AWSS3Service class?. Is there any documentation for using this?

mutablealligator commented 6 years ago

It would be this one: http://docs.aws.amazon.com/AWSiOSSDK/latest/Classes/AWSS3.html

nick3389 commented 6 years ago

Does it support handleEventsForBackgroundURLSession?

mutablealligator commented 6 years ago

The AWSS3 client (http://docs.aws.amazon.com/AWSiOSSDK/latest/Classes/AWSS3.html) doesn't support background transfers. The AWSS3TransferUtility only supports background transfers.

nick3389 commented 6 years ago

Ok. So, I guess I am stuck with AWSS3TransferUtility. Is there any plan to support background transfers with the AWSS3 client?

scb01 commented 6 years ago

Hello nick3389

Thank you for your continued feedback on this topic. The TransferUtility component currently has a hard limit of 50 minutes as already mentioned by kvasukib. I have added the following enhancements requests to the SDK backlog.

Please check back on this thread ( or look for general forum announcements) for updates on these items.

That said, if you are currently blocked and need a solution for longer lived background uploads, you can do a background transfer with S3 using pre-signed URLs and NSURLSession. (see https://docs.aws.amazon.com/mobile/sdkforios/developerguide/s3-pre-signed-urls.html for further details)

chrisscholly commented 6 years ago

Would be so nice if AWSS3TransferUtility could have a configurable timeout. So, I am also stuck with that at the moment :(

chrisscholly commented 6 years ago

@nick3389 Have you found any solution for the moment?

nick3389 commented 6 years ago

@chrisscholly no. I still use transfer utility, but every time I do a pod update, I change manually the timeoutInterval. Probably I will wait for the changes @cbommas mentioned. For now, I leave it as it is.

chrisscholly commented 6 years ago

@nick3389 Thank you for the update. Changing manually the timeoutInterval is enough to overcome the 50 minutes limitation? @cbommas @kvasukib could you also confirm?

nick3389 commented 6 years ago

@chrisscholly Yes, it's working.

chrisscholly commented 6 years ago

@nick3389 Are you sure? Only by tweaking the timeoutInterval? Seems like we should also pass in credentials to the TransferUtility instead of letting Cognito Identity retrieve temporary credentials.

nick3389 commented 6 years ago

@chrisscholly Sorry, I forgot to mention that I don't use Cognito. I use accessKey and secretKey for S3 (static credentials). You should setup your own defaultServiceConfiguration and then register in AWSS3TransferUtility with: + (void)registerS3TransferUtilityWithConfiguration:(AWSServiceConfiguration *)configuration forKey:(NSString *)key;

chrisscholly commented 6 years ago

@nick3389 Okay, thank you, will have a try :)

chrisscholly commented 6 years ago

@nick3389 Seems like it works like a charm 👌 Thanks bro!

chrisscholly commented 6 years ago

@nick3389 Just noticed that TransferUtility does not support multi-parts 😔 So it will be very tricky to upload large files. What is your strategy in terms of network loss, pause/resume, etc.?

scb01 commented 6 years ago

@chrisscholly We are working on adding multi-part functionality to the Transfer Utility and adding enhanced error handling/retry to tackle network loss, pause/resume etc. Please check back on this thread (or look for general forum announcements) for updates on these items.

stale[bot] commented 6 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] commented 6 years ago

This issue has been automatically closed because of inactivity. Please open a new issue if are still encountering problems.

mutablealligator commented 6 years ago

We have added support for Mulit-part in uploads in AWSS3TransferUtility in 2.6.13. Please upgrade and let us know any feedback you have.

mutablealligator commented 6 years ago

Hello @nick3389 @chrisscholly

The latest version of the SDK, 2.6.20 released on 6/1/2018, contains this feature.

    let serviceConfiguration = AWSServiceManager.default().defaultServiceConfiguration
    let transferUtilityConfiguration = AWSS3TransferUtilityConfiguration()
    //Set the timeoutIntervalForResource parameter (in seconds)
    transferUtilityConfigurationWithRetry.timeoutIntervalForResource = 15*60 //15 minutes

    AWSS3TransferUtility.register(
        with: serviceConfiguration!,
        transferUtilityConfiguration: transferUtilityConfiguration,
        forKey: "custom-timeout"
    )

    //Instantiate the transfer utility
    let transferUtility = AWSS3TransferUtility.s3TransferUtility(forKey: "custom-timeout")