Parul singh chauhan
Parul singh chauhan

Reputation: 1

How to copy/download all versions of a file inside S3 java

I'm trying to find a way to download or copy all versions of a file from S3 to S3 bucket in different folde.

Upvotes: 0

Views: 204

Answers (1)

John Rotenstein
John Rotenstein

Reputation: 269500

Each version of an object within S3 is (sort of) a separate object. They just happen to share the same Key.

It is not possible to copy an object together with all of its versions.

Instead, you would need to copy each version individually, starting with the earliest version through to the most recent version (so that they 'stack up' in the correct order).

The copy can be performed with the CopyObject() method, specifying a sourceVersionId. The newly copied version will have a different ID.

Same-Region Replication and Cross-Region Replication can retain object versions, but can only copy to a different bucket (not to different directories).

Upvotes: 1

Related Questions