Fahima Hyder
Fahima Hyder

Reputation: 1

Boto3 listing files within an s3 object

is there a way to use boto3 to print the filenames within an s3 bucket object?

the bucket looks like this

  1. Bucket

Is there a way to use boto3 to print the names of files?

Upvotes: 0

Views: 96

Answers (1)

David
David

Reputation: 36444

Of course, like so

client = boto3.client('s3')
objects = client.list_objects(Bucket='yourbucketnamegoeshere')
for obj in objects['Contents']:
    print(obj['Key'])

Done

Upvotes: 1

Related Questions