0

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

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470
  • Please be more clear about your question, what kind of file is it (.txt, or .csv) and what is the source directory and destination directory! – anjandash Feb 15 '21 at 08:32
  • Can you tell us what you are wanting to achieve? That is, _why_ are you wanting to do this? There might be an alternative way to achieve your goals. – John Rotenstein Feb 15 '21 at 11:04
  • @anjandash, I was trying to copy .txt and BIM files (Building information modeling). I was able to achieve my goal using s3versionsummary. – Parul singh chauhan Dec 14 '21 at 04:49
  • @JohnRotenstein , Actually the main task was to download S3 files in the system but we don't have that permission so I was just trying to store it in other s3 bucket to see if my code will work or not... But that requirement was discarded. – Parul singh chauhan Dec 14 '21 at 04:53

1 Answers1

1

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).

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470