/**
* This state represents a transfer that has been queued, but has not yet
* started
*/
WAITING,
/**
* This state represents a transfer that is currently uploading or
* downloading data
*/
IN_PROGRESS,
/**
* This state represents a transfer that is paused
*/
PAUSED,
/**
* This state represents a transfer that has been resumed and queued for
* execution, but has not started to actively transfer data
*/
RESUMED_WAITING,
/**
* This state represents a transfer that is completed
*/
COMPLETED,
/**
* This state represents a transfer that is canceled
*/
CANCELED,
/**
* This state represents a transfer that has failed
*/
FAILED,
/**
* This state represents a transfer that is currently on hold, waiting for
* the network to become available
*/
WAITING_FOR_NETWORK,
/**
* This state represents a transfer that is a completed part of a multi-part
* upload. This state is primarily used internally and there should be no
* need to use this state.
*/
PART_COMPLETED,
/**
* This state represents a transfer that has been requested to cancel, but
* the service processing transfers has not yet fulfilled this request. This
* state is primarily used internally and there should be no need to use
* this state.
*/
PENDING_CANCEL,
/**
* This state represents a transfer that has been requested to pause by the
* client, but the service processing transfers has not yet fulfilled this
* request. This state is primarily used internally and there should be no
* need to use this state.
*/
PENDING_PAUSE,
/**
* This state represents a transfer that has been requested to pause by the
* client because the network has been loss, but the service processing
* transfers has not yet fulfilled this request. This state is primarily
* used internally and there should be no need to use this state.
*/
PENDING_NETWORK_DISCONNECT,
/**
* This is an internal value used to detect if the current transfer is in an
* unknown state
*/
UNKNOWN;
我使用下面的代码从互联网上下载一个文件。
TransferObserver observer = transferUtil.download(Bucketname, key, file);
observer.setTransferListener(new TransferListener() {
@Override
public void onStateChanged(int i, TransferState transferState) {
Log.d("AWS download state", transferState.toString());
if (transferState == TransferState.COMPLETED) {
}else if(transferState == TransferState.CANCELED){
}else if(transferState == TransferState.FAILED){
}else if((transferState == TransferState.WAITING) || (transferState == TransferState.WAITING_FOR_NETWORK)){
}
}
@Override
public void onProgressChanged(int i, long l, long l1) {
}
@Override
public void onError(int i, Exception e) {
Log.e("aws error", e.toString());
}
});
这些代码中的哪一个表示在互联网上下载失败?可能还有其他错误,如:-
服务器无法提供所请求的文件等。如何区分这些文件?
发布于 2018-05-13 06:52:58
TransferState.FAILED
表示传输失败时的状态。当传输达到此状态时,传输将不再继续,并且处于终止状态。
您可以检查TransferState.FAILED
并决定是否要重新启动传输或将异常报告回客户。
https://stackoverflow.com/questions/50232693
复制相似问题