Reputation: 3935
I am using Python 3.6 and boto3 library to work with some objects in s3 bucket. I have created some S3 objects with metadata entries. For example,
bucketName = 'Boto3'
objectKey = 'HelloBoto.txt'
metadataDic = {'MetadataCreator':"Ehxn"}
Now I am wondering if it is possible to filter and get only those objects which have a certain metadata entry, for example,
for obj in s3Resource.Bucket(bucketName).objects.filter(Metadata="Ehsan ul haq"):
print('{0}'.format(obj.key))
Upvotes: 0
Views: 2881
Reputation: 269181
No. The list_objects()
command does not accept a filter.
You would need to call head_object()
to obtain the metadata for each individual object.
Alternatively, you could activate Amazon S3 Inventory - Amazon Simple Storage Service, which can provide a daily listing of all objects with metadata.
Upvotes: 4