1

I am uploading/downloading files using the Storage API of the AWS Amplify SDK library for Android.

I need to show progress as the operation is going on. Is there any way in the Amplify Storage API to hook a listener or callback such I can listen for upload/download progress, in order to update a progress bar in the UI?

The official documentation does not mention anything for it: https://aws-amplify.github.io/docs/android/storage

If not, I think there are two alternatives:

  • TransferUtility / TransferObserver - It has API to observe progress, but I can't get it to work with Cognito User pools. I don't know if the API allows that.
  • Generate a presigned url in the server, and then use HttpUrlConnection or OkHttp - this would give me access to the underlying InputStream and I could report progress as it's been read, but I find this very low level and I was hoping to be able to delegate into any of the AWS SDKs.

Thank you.

GaRRaPeTa
  • 5,459
  • 4
  • 37
  • 61
  • After more research, my conclusion is that the `Storage` API does not allow to listen for progress. This can be done with `TransferUtility`, and instructions on how to authenticate `TransferUtility` requests with Cognito user pools are found in https://stackoverflow.com/questions/59372773/how-to-use-transferutility-with-cognito-user-identity-pools-in-android/59372934#59372934 – GaRRaPeTa Dec 17 '19 at 11:11

1 Answers1

0

You can use TransferObserver with TransferListener.

https://aws-amplify.github.io/aws-sdk-android/docs/reference/com/amazonaws/mobileconnectors/s3/transferutility/TransferObserver.html

It provides you progress of file being transferred.

  • Yes, looks like this is only possible with `TransferUtility` (as stated in my question). However, authenticating `TransferUtility` requests with Cognito user pools is the tricky bit that I could not manage to get working and made me consider the `Storage` API insted. This is solved in https://stackoverflow.com/questions/59372773/how-to-use-transferutility-with-cognito-user-identity-pools-in-android/59372934#59372934 – GaRRaPeTa Dec 17 '19 at 11:08