6

I have a small Java program that enables a user to Upload/Download files to/from Amazon S3. I have a 'Cancel' button and would like to cancel the transfer once this button is pressed.

It looks like there is an abort() method when Downloading which seems to be working, however I am not sure how to go about aborting an Upload. I am using a TransferManager to upload the files. I have tried calling transferManager.shutdownNow() along with transferManager.abortMultipartUploads(), however the file still shows up in the S3 Management Console as if the transfer was not aborted. Am I doing something wrong?

4

2 回答 2

1

在我的程序中,我调用transferManager.upload()方法上传一个PutObjectRequest对象,然后它返回一个Upload对象,其中包含abort()API。所以我只是打电话upload.abort()取消转移。我希望这有帮助。:)

于 2017-07-10T07:56:49.563 回答
-1

我建议您保留所有取消请求的队列,一旦文件完成上传到 S3,您就对该 S3 对象执行删除操作并将该文件从取消队列中删除。这可能是真正“取消”上传的最简单的方法。

于 2013-06-07T20:10:04.697 回答