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 個月前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南