How to change a oldest version object to latest version object in aws s3 without deleting new versions

Viewed 1499

In aws s3 versioning enabled buckets we can upload same name objects, it preserved in buckets with version Id. If i upload 10 versions in a bucket the latest version is which was i upload last.

If i want to make my 4th version as latest version, one way to do this removing all latest 6 versions it automatically change the 4th version as a latest version.

Another way is re upload a version 4 , it takes as 11th version & also it is a latest version. We upload a existing object with its old version ID.

How we can do the second way in AWS command line interface ?

1 Answers

I found Solution to re upload object with its older version Id. "copy-object" command can be used.

aws s3api copy-object --bucket YOUR BUCKET--key img.jpg --copy-source "YOUR BUCKET/img.jpg?versionId=fRP7UzABrXTsBgBu9WAhZ0VgU3pif9Lp" --acl public-read

it copy the old version as new version ...

Related