中止AWS S3上传 [英] Aborting AWS S3 Uploads

查看:654
本文介绍了中止AWS S3上传的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个小的Java程序,使用户从亚马逊S3上传/下载文件到/。我有一个取消按钮,想取消传输一旦这个按钮是pressed。

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.

它看起来像有一个中止()方法时下载这似乎是工作,但我不知道如何去中止上载。我使用的是TransferManager上传的文件。我已经打过电话 transferManager.shutdownNow()以及 transferManager.abortMultipartUploads(),但文件仍显示在S3的管理控制台,如果传输不中断。难道我做错了什么?

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?

推荐答案

我建议你把你所有的取消请求队列,一旦文件完成后上传到S3,执行一个S3对象上的删除操作和删除该文件从取消队列。这可能是最防呆的方式来真正的取消上传。

I recommend that you keep a queue of all your cancel requests, and once the file completes uploading to S3, you execute a delete action on that S3 object and remove that file from the cancel queue. That might be the most fool-proof way to truly "cancel" an upload.

这篇关于中止AWS S3上传的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆