How to properly and completely terminate a multipart upload?

0

In our Java app we have what is basically boilerplate S3 V2 code for creating a multipart upload of a file to S3. We absolutely need the ability to cancel the upload, and recover all resources used by the upload process, INCLUDING the CPU and network bandwidth. Initially we tried simply cancelling the completionFuture on the FileUpload, but that doesn't work. I can watch the network traffic continue to send data to S3, until the entire file is uploaded. Cancelling the completionFuture seems to stop S3 from reconstructing the file, but that's not sufficient. In most cases we need to cancel the upload because we need the network bandwidth for other things, like streaming video.

I found the function shutdownNow() in the TransferManager class, and that seemed promising, but it looks like it's not available in the V2 SDK (I found it in the V1 sources).

I've seen a function getSubTransfers() in the V1 MultipleFileUpload class that returns a list of Uploads, and the Upload class has an abort() function, but again, we need to use V2 for other reasons.

I've also found and implemented code that calls listMultipartUploads, looks for the upload we want to cancel, creates an abortMultipartUploadRequest, issues it and the threads keep on rolling, and rolling, and rolling....

Is there a "correct" way of terminating a multipart upload, including the threads processing the upload?

質問済み 2年前284ビュー
1回答
0

Hello,

The TransferManager class contains an abortMultipartUploads method that would allow you to halt multiple multipart uploads in progress. To abort a specific multipart upload, you’ll need to use a lower-level API called abortMultipartUpload under the S3 client class. This method would delete any parts uploaded to Amazon S3 and free up the associated resources, given the upload ID, bucket name, and object key.

The reference page below contains instructions and example code in Java and .NET for aborting a multipart upload:

https://docs.aws.amazon.com/AmazonS3/latest/userguide/abort-mpu.html

回答済み 9ヶ月前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ