Skip to content
Advertisement

Amazon S3 boto3 how to iterate through objects in a bucket?

In a flask app, I was trying to iterate through objects in a S3 Bucket and trying to print the key/ filename but my_bucket.objects.all() returns only the first object in the bucket. It’s not returning the all the objects. The output is [001.pdf] instead of [001, 002, 003, 004, 005]

JavaScript

Advertisement

Answer

You are exiting the loop by returning too early.

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement