terricain / aioboto3

Wrapper to use boto3 resources with the aiobotocore async backend
Apache License 2.0
748 stars 76 forks source link

`head_object` or an async way to check if object exists in an S3 bucket. #346

Open etep opened 3 months ago

etep commented 3 months ago

Description

Using boto3, one can check if an object exists in a bucket using method head_object, see, e.g.: https://stackoverflow.com/questions/33842944/check-if-a-key-exists-in-a-bucket-in-s3-using-boto3

The head_object method does not appear to be implemented in aioboto3.

mjpieters commented 1 month ago

What makes you think it isn't implemented? head_object is a method defined in the S3 service description, and works just fine:

session = aioboto3.Session()
async with session.client("s3") as client:
    await client.head_object(Bucket="bucket-name", Key="object-key")