how to fix key error in listing content from a s3 bucket in aws?

Question:

I have following piece of code, that utilizes list_objects_v2 from boto3. I get an error => keyError : ‘Contents’. I am assuming if name of the file i’m passing doesn’t exist , it throws this error.

Answer:

It should be Contents, not contents, assuming some objects are returned:

Leave a Reply