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

Viewed 587

I am using transfer manager available in AWS SDK for file upload and download.Upload and download method returns Upload , Download Object respectively. I am using the isDone() method to check if the upload/download is finished.Now isDone() method returns true even when TransferState is FAILED. I need to know the error or exception that has occurred which has caused this failure. How can i do that.

1 Answers

By the definition and documentation;

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

What you may use;

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

Maybe this one

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

Both are blocking calls but throws exceptions which includes details.

Related