aws-amplify / amplify-swift

A declarative library for application development using cloud services.
Apache License 2.0
455 stars 196 forks source link

Support long running background uploads/downloads #1559

Closed nick3389 closed 4 months ago

nick3389 commented 2 years ago

Is your feature request related to a problem? Please describe.

The main scope is to support uploads mainly while the application is in the background. Currently this is not supported by Amplify SDK. You can read more about it in #638 .

Secondly, there is no support for setting up a AWSServiceConfiguration with AWSStaticCredentialsProvider in Amplify.

Describe the solution you'd like

A possible solution would be something like AWSTransferUtility that aws-ios-sdk has and supports background uploads. Also, AWSTransferUtility can be setup with a AWSStaticCredentialsProvider. However, the main issue here is the support of long running background uploads.

Describe alternatives you've considered

No alternative with Amplify SDK. I still use the aws-ios-sdk.

Is the feature request related to any of the existing Amplify categories?

No response

Additional context

No response

brennanMKE commented 2 years ago

See Discussion :

jcjimenez commented 1 year ago

Hi, @nick3389, the AWSS3StoragePlugin in Amplify version 2 uses a background URLSession so that downloads can continue even when the application is in the background:

https://github.com/aws-amplify/amplify-swift/blob/main/AmplifyPlugins/Storage/Sources/AWSS3StoragePlugin/Service/Storage/AWSS3StorageService.swift#L73

Would you please let us know if this was what you were referring to?

nick3389 commented 1 year ago

Hi @jcjimenez,

Does this support uploads as well?

jcjimenez commented 1 year ago

Hi, @nick3389,

Yes, this works for uploads also. However, there's one caveat: if the size of the file being uploading is larger than 5MB, then the upload will be split into separate [part] upload tasks. So, any tasks that are in progress when the app goes to the background will proceed, and if connectivity remains stable, will complete successfully. However, any subsequent [part] tasks will depend on the app coming back into the foreground so they can be started.

In other words, imagine the file being uploaded is divided into 10 parts and the first 3 start immediately after the call to Amplify.Storage.uploadFile. These 3 tasks will continue even after your app goes into the background. However, the other remaining 7 tasks will be created by the app when one or more of the first 3 complete successfully.

nick3389 commented 1 year ago

Hi @jcjimenez

Thank you for the response. However, the 7 remaining tasks will be completed even if the app is in the background? Or does the app needs to be in the foreground again, complete the 3 tasks and then the rest 7 to start launching?

github-actions[bot] commented 4 months ago

This issue is now closed. Comments on closed issues are hard for our team to see. If you need more assistance, please open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.