I want to only print the top level folders in my s3 bucket, how can i go about doing that?
client = boto3.client('s3', region_name='us-west-2')
paginator = client.get_paginator('list_objects')
page_iterator = paginator.paginate(Bucket='my-bucket')
for page in page_iterator:
print(page['Contents'])
Here is what i have above,
but let say my folder structure is as so
folder1/folder/file
folder2/folder/file
folder2/folder/file2
folder3/file
How can i make it so only the top level folder name prints? So it looks like this below:
folder1
folder2
folder2
folder3
I am also using paginate because i have thousands. otherwise doing a list_objects will only print 1000.
Thanks!