AWS文件传输错误

时间:2018-05-08 11:39:05

标签: android amazon-web-services amazon-s3

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>

所有这些代码表明下载在互联网上失败了? 可能还有其他错误,如: -

服务器无法提供所请求的文件等。如何区分这些?

1 个答案:

答案 0 :(得分:0)

TransferState.FAILED表示失败时的转移状态。当转移到达该状态时,转移不再进行并且它是终止状态。

您可以检查TransferState.FAILED并决定是否要重新启动转移或将异常报告给客户。