0 votes
1 view
in AWS by (18.7k 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?

1 Answer

0 votes
by (43.5k 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 (18.7k points)
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...