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

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


You are exiting the loop by returning too early.

def list_of_files():    s3_resource = boto3.resource('s3')    my_bucket = s3_resource.Bucket(S3_BUCKET)    summaries = my_bucket.objects.all()    files = []    for file in summaries:        files.append(file.key)    return jsonify({"files": files})