head_object#

Improve the head_object API.

s3pathlib.better_client.head_object.head_object(s3_client: S3Client, bucket: str, key: str, if_match: str = Sentinel('NOTHING'), if_modified_since: datetime = Sentinel('NOTHING'), if_none_match: str = Sentinel('NOTHING'), if_unmodified_since: datetime = Sentinel('NOTHING'), range: str = Sentinel('NOTHING'), version_id: str = Sentinel('NOTHING'), sse_customer_algorithm: str = Sentinel('NOTHING'), sse_customer_key: str = Sentinel('NOTHING'), request_payer: str = Sentinel('NOTHING'), part_number: int = Sentinel('NOTHING'), expected_bucket_owner: str = Sentinel('NOTHING'), checksum_mode: str = Sentinel('NOTHING'), ignore_not_found: bool = False) dict | HeadObjectOutputTypeDef | None[source]#

Wrapper of head_object.

Example:

>>> response = head_object(s3_client, "my-bucket", "file.txt")
>>> if response is None:
...     print("Object not found")
... else:
...     print(response["LastModified"])
Parameters:
Returns:

See head_object

s3pathlib.better_client.head_object.is_object_exists(s3_client: S3Client, bucket: str, key: str, version_id: str = Sentinel('NOTHING')) bool[source]#

Check if an object exists. If you want to use the head_object API response immediately when the object exists, use head_object() instead.

Example:

>>> is_object_exists(s3_client, "my-bucket", "file.txt")
True
Parameters:
Returns:

A Boolean flag to indicate whether the object exists.