Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Aborting AWS S3 Uploads

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?

like image 755
Tommo Avatar asked Nov 19 '12 15:11

Tommo


People also ask

What happens if you upload the same file to S3?

By default, when you upload the file with same name. It will overwrite the existing file. In case you want to have the previous file available, you need to enable versioning in the bucket.

Does S3 charge for delete files?

Reference the S3 developer guide for technical details on the following request types: PUT, COPY, POST, LIST, GET, SELECT, Lifecycle Transition, and Data Retrievals. DELETE and CANCEL requests are free. LIST requests for any storage class are charged at the same rate as S3 Standard PUT, COPY, and POST requests.

What happens to an object when we delete it from Amazon S3?

If the version ID maps to a specific object version, Amazon S3 deletes the specific version of the object. If the version ID maps to the delete marker of that object, Amazon S3 deletes the delete marker. This makes the object reappear in your bucket.


1 Answers

In my program, I call transferManager.upload() method to upload a PutObjectRequestobject, and then it returns an Upload object, which contains abort() API. So I just call upload.abort() to cancel the transfer. I hope this helps.:)

like image 123
Shaw Avatar answered Sep 24 '22 23:09

Shaw