Page updated Nov 12, 2023

Query transfers

When an upload or download operation is requested using the Amplify Android library, the request is first persisted in the local SQLite Database and then queued for execution. You can query the transfer operation queued in the local database using the transfer ID returned by an upload or download API. Get-Transfer API could retrieve a pending transfer previously en-queued and enable attaching a listener to receive updates on progress change, on-error or on-success, or pause, cancel or resume it.

1Amplify.Storage.getTransfer("TRANSFER_ID",
2 operation -> {
3 Log.i("MyAmplifyApp", "Current State" + operation.getTransferState());
4 // set listener to receive updates
5 operation.setOnProgress( progress -> {});
6 operation.setOnSuccess( result -> {});
7 operation.setOnError(error -> {});
8
9 // possible actions
10 operation.pause();
11 operation.resume();
12 operation.start();
13 operation.cancel();
14 },
15 {
16 error -> Log.e("MyAmplifyApp", "Failed to query transfer", error)
17 }
18);
1Amplify.Storage.getTransfer("TRANSFER_ID",
2 { operation ->
3 Log.i("MyAmplifyApp", "Current State" + operation.transferState)
4 // set listener to receive updates
5 operation.setOnProgress { }
6 operation.setOnSuccess { }
7 operation.setOnError { }
8
9 // possible actions
10 operation.pause()
11 operation.resume()
12 operation.start()
13 operation.cancel()
14 },
15 {
16 Log.e("MyAmplifyApp", "Failed to query transfer", it)
17 }
18)
1try {
2 val operation = Amplify.Storage.getTransfer("TRANSFER_ID")
3 Log.i("MyAmplifyApp", "Current State" + operation.transferState)
4 // set listener to receive updates
5 operation.setOnProgress { }
6 operation.setOnSuccess { }
7 operation.setOnError { }
8
9 // possible actions
10 operation.pause()
11 operation.resume()
12 operation.start()
13 operation.cancel()
14} catch (error: StorageException) {
15 Log.e("MyAmplifyApp", "Failed to query transfer", error)
16}
1RxAmplify.Storage.getTransfer("TRANSFER_ID")
2 .subscribe(
3 operation -> {
4 Log.i("MyAmplifyApp", "Current State" + operation.getTransferState());
5 // set listener to receive updates
6 operation.setOnProgress( progress -> {});
7 operation.setOnSuccess( result -> {});
8 operation.setOnError(error -> {});
9
10 // possible actions
11 operation.pause();
12 operation.resume();
13 operation.start();
14 operation.cancel();
15 },
16 error -> Log.e("MyAmplifyApp", "Failed to query transfer", error);
17 );