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());
}
});
我使用以下代码从互联网上下载文件。
<div class="summary-card">
<div>
<div style="background-color: #ccc !important;">
11111 my custom div
</div>
</div>
<div class="cool-grid">
<div class="card">
<div class="card-title" style="text-align: left;">{{cardData.label}}</div>
<div class="card-data">
.....
</div>
</div>
<div class="card">
<div class="card-title" style="text-align: left;">{{cardData.label}}</div>
<div class="card-data">
.....
</div>
</div>
<div class="card">
<div class="card-title" style="text-align: left;">{{cardData.label}}</div>
<div class="card-data">
.....
</div>
</div>
<div class="card">
<div class="card-title" style="text-align: left;">{{cardData.label}}</div>
<div class="card-data">
.....
</div>
</div>
</div>
</div>
所有这些代码表明下载在互联网上失败了? 可能还有其他错误,如: -
服务器无法提供所请求的文件等。如何区分这些?
答案 0 :(得分:0)
TransferState.FAILED
表示失败时的转移状态。当转移到达该状态时,转移不再进行并且它是终止状态。
您可以检查TransferState.FAILED
并决定是否要重新启动转移或将异常报告给客户。