Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Retrieve deleted AWS S3 file by version

I am trying to retrieve a deleted file from s3, without restoring it. I can do it through the console (clicking Download), but I need to do it programmatically.

The following call lists the version I need:

s3.list_object_versions(
    Bucket="...", 
    KeyMarker="/.../part-00000-5ceb032b-c918-47df-a2ad-f02f3790077a-c000.csv", 
    VersionIdMarker = "A1GxocexjsirkzKfo47lvQ0r7ythwCWM",
    MaxKeys=1
)

However, s3.get_object() with the same parameters, returns "ClientError: An error occurred (NoSuchVersion) when calling the GetObject operation: The specified version does not exist."

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

What is the proper way of retrieving a specific version of a deleted file?

>Solution :

Based on the comments. The issue was caused by using / in a key a prefix. Prefixes do not start with a /. Thus it should be:

KeyMarker=".../part-00000-5ceb032b-c918-47df-a2ad-f02f3790077a-c000.csv"
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading