文件上传下载传输状态为FAILED时如何知道错误/异常

How to know the error / exception when file upload download transfer state is FAILED

我正在使用 AWS SDK 中提供的传输管理器进行文件上传,download.Upload 和下载方法 returns 分别上传、下载对象。我正在使用 isDone() 方法检查 upload/download 是否为 finished.Now isDone() 方法 returns true,即使 TransferState 失败也是如此。我需要知道导致此失败的错误或异常。我该怎么做。

根据定义和documentation;

isDone Returns true if this transfer is finished (i.e. completed successfully, failed, or was canceled). Returns false if otherwise.

你可能会用到什么;

waitForCompletion: Waits for this transfer to complete. This is a blocking call; the current thread is suspended until this transfer completes. details here

也许是这个

waitForException: Waits for this transfer to finish and returns any error that occurred, or returns null if no errors occurred. This is a blocking call; the current thread will be suspended until this transfer either fails or completes successfully. details here

两者都是 blocking 调用,但抛出包含详细信息的异常。