Back

Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
in AWS by (19.1k points)

How can I see what's inside a bucket in S3 with boto3? (i.e. do an "ls")?

Doing the following:

import boto3

s3 = boto3.resource('s3')

my_bucket = s3.Bucket('some/path/')

returns:

s3.Bucket(name='some/path/')

How do I see its contents?

closed

1 Answer

0 votes
by (44.3k points)
selected by
 
Best answer

One way to do it:

for my_bucket_object in my_bucket.objects.all():

    print(my_bucket_object)

Related questions

0 votes
1 answer
asked Jul 23, 2019 in AWS by yuvraj (19.1k points)

Want to get 50% Hike on your Salary?

Learn how we helped 50,000+ professionals like you !

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
Welcome to Intellipaat Community. Get your technical queries answered by top developers!

28.4k questions

29.7k answers

500 comments

94k users

Browse Categories

...