dsaiztc
4/27/2017 - 9:01 AM

Boto3 tricks.

Boto3 tricks.

def list_objects_s3(s3_client, s3_bucket, s3_prefix):
    """List objects in S3 overcoming the limit of 1000 per usual request."""
    s3_paginator = s3_client.get_paginator('list_objects')
    page_iterator = s3_paginator.paginate(Bucket=s3_bucket, Prefix=s3_prefix)
    for page in page_iterator:
        object_list = page.get('Contents')
        for object in object_list:
            yield object