head_object

Improve the head_object API.

s3pathlib.better_client.head_object.head_object(s3_client: S3Client, bucket: str, key: str, if_match: str = OPT, if_modified_since: datetime = OPT, if_none_match: str = OPT, if_unmodified_since: datetime = OPT, range: str = OPT, version_id: str = OPT, sse_customer_algorithm: str = OPT, sse_customer_key: str = OPT, request_payer: str = OPT, part_number: int = OPT, expected_bucket_owner: str = OPT, checksum_mode: str = OPT, 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 = OPT) 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.