public class TransferObserver
extends java.lang.Object
For example, you can track the progress of an upload as the following:
TransferObserver transfer = transferUtility.upload(bucket, key, file); transfer.setListener(new TransferListener() { public onProgressChanged(int id, long bytesCurrent, long bytesTotal) { // update progress bar progressBar.setProgress(bytesCurrent); } public void onStateChanged(int id, TransferState state) { } public void onError(int id, Exception ex) { } });
Note that callbacks of a listener will be invoked on the main thread.
Modifier and Type | Method and Description |
---|---|
void |
cleanTransferListener()
Cleans the transfer listener.
|
java.lang.String |
getAbsoluteFilePath()
Gets the absolute path of file to transfer.
|
java.lang.String |
getBucket()
Gets the bucket name of the record.
|
long |
getBytesTotal()
Gets the total bytes to transfer.
|
long |
getBytesTransferred()
Gets the bytes transferred currently.
|
int |
getId()
Gets the transfer id of the record.
|
java.lang.String |
getKey()
Gets the key of the record.
|
TransferState |
getState()
Gets the state of the transfer task.
|
void |
refresh()
Refresh fields in the TransferObserver from the running transfer task.
|
void |
setTransferListener(TransferListener listener)
Sets a listener used to receive notification when state or progress
changes.
|
java.lang.String |
toString() |
public void refresh()
public void setTransferListener(TransferListener listener)
Note that callbacks of the listener will be invoked on the main thread.
listener
- A TransferListener used to receive notification.public int getId()
public java.lang.String getBucket()
public java.lang.String getKey()
public long getBytesTotal()
public java.lang.String getAbsoluteFilePath()
public long getBytesTransferred()
public TransferState getState()
public void cleanTransferListener()
public java.lang.String toString()
toString
in class java.lang.Object
Copyright © 2018 Amazon Web Services, Inc. All Rights Reserved.