am trying to scroll over all buckets in s3 and see if there is a prefix that matches and get into those folders and read the json files.
I have tried to get the folders that contain a prefix, but failing to enter them.
Code:
import boto3
bucket = ['test-eob', 'test-eob-images']
client = boto3.client('s3')
for i in bucket:
result = client.list_objects(Bucket=i,Prefix = 'PROCESSED_BY/FILE_JSON', Delimiter='/')
print(result)
Using this am getting the ones with prefix and fails when bucket doesnt have that prefix.
structure of test-eob , test-eob/PROCESSED_BY/FILE_JSON/*.json
I have to read the json if only my prefix matches, else come out of the bucket.
Can anyone help me out here.