Skip to content

S3Client.head_object

rboto-s3==0.4.0 · Service index · Types

Model summary (excerpt): The HEAD operation retrieves metadata from an object without returning the object itself. This operation is useful if you're interested only in an object's metadata. A HEAD request has the same options as a GET operation on an object. The response is identical to the GET response except that there is no response body. Because of this, if the HEAD request generates an error, it returns a...

Install and imports

python -m pip install "rboto[s3]==0.4.0"
from rboto import S3Client
from rboto_s3.types import (
    ChecksumMode,
    HeadObjectOutput,
    RequestPayer,
)

Signature

async def head_object(
    *,
    bucket: str,
    key: str,
    if_match: str | None = None,
    if_modified_since: str | None = None,
    if_none_match: str | None = None,
    if_unmodified_since: str | None = None,
    range: str | None = None,
    response_cache_control: str | None = None,
    response_content_disposition: str | None = None,
    response_content_encoding: str | None = None,
    response_content_language: str | None = None,
    response_content_type: str | None = None,
    response_expires: str | None = None,
    version_id: str | None = None,
    sse_customer_algorithm: str | None = None,
    sse_customer_key: str | None = None,
    sse_customer_key_md5: str | None = None,
    request_payer: RequestPayer | None = None,
    part_number: int | None = None,
    expected_bucket_owner: str | None = None,
    checksum_mode: ChecksumMode | None = None,
) -> HeadObjectOutput: ...

Arguments without defaults are required. None omits an optional request argument. Static types do not validate resource existence, permissions, lengths, ranges, or conditional service requirements.

Arguments

Argument Required Model notes (excerpt)
bucket Yes The name of the bucket that contains the object. Directory buckets - When you use this operation with a directory bucket, you must use virtual-hosted-style requests in the format Bucket-name .s3express- zone-id . region-code .amazonaws.com . Path-style requests are not supported. Directory bucket names must be unique in the chosen Zone (Availability Zone or Local Zone). Bucket names must...
key Yes The object key.
if_match No Return the object only if its entity tag (ETag) is the same as the one specified; otherwise, return a 412 (precondition failed) error. If both of the If-Match and If-Unmodified-Since headers are present in the request as follows: If-Match condition evaluates to true , and; If-Unmodified-Since condition evaluates to false ; Then Amazon S3 returns 200 OK and the data requested. For more...
if_modified_since No Return the object only if it has been modified since the specified time; otherwise, return a 304 (not modified) error. If both of the If-None-Match and If-Modified-Since headers are present in the request as follows: If-None-Match condition evaluates to false , and; If-Modified-Since condition evaluates to true ; Then Amazon S3 returns the 304 Not Modified response code. For more information...
if_none_match No Return the object only if its entity tag (ETag) is different from the one specified; otherwise, return a 304 (not modified) error. If both of the If-None-Match and If-Modified-Since headers are present in the request as follows: If-None-Match condition evaluates to false , and; If-Modified-Since condition evaluates to true ; Then Amazon S3 returns the 304 Not Modified response code. For more...
if_unmodified_since No Return the object only if it has not been modified since the specified time; otherwise, return a 412 (precondition failed) error. If both of the If-Match and If-Unmodified-Since headers are present in the request as follows: If-Match condition evaluates to true , and; If-Unmodified-Since condition evaluates to false ; Then Amazon S3 returns 200 OK and the data requested. For more information...
range No HeadObject returns only the metadata for an object. If the Range is satisfiable, only the ContentLength is affected in the response. If the Range is not satisfiable, S3 returns a 416 - Requested Range Not Satisfiable error.
response_cache_control No Sets the Cache-Control header of the response.
response_content_disposition No Sets the Content-Disposition header of the response.
response_content_encoding No Sets the Content-Encoding header of the response.
response_content_language No Sets the Content-Language header of the response.
response_content_type No Sets the Content-Type header of the response.
response_expires No Sets the Expires header of the response.
version_id No Version ID used to reference a specific version of the object. For directory buckets in this API operation, only the null value of the version ID is supported.
sse_customer_algorithm No Specifies the algorithm to use when encrypting the object (for example, AES256). This functionality is not supported for directory buckets.
sse_customer_key No Specifies the customer-provided encryption key for Amazon S3 to use in encrypting data. This value is used to store the object and then it is discarded; Amazon S3 does not store the encryption key. The key must be appropriate for use with the algorithm specified in the x-amz-server-side-encryption-customer-algorithm header. This functionality is not supported for directory buckets.
sse_customer_key_md5 No Specifies the 128-bit MD5 digest of the encryption key according to RFC 1321. Amazon S3 uses this header for a message integrity check to ensure that the encryption key was transmitted without error. This functionality is not supported for directory buckets.
request_payer No
part_number No Part number of the object being read. This is a positive integer between 1 and 10,000. Effectively performs a 'ranged' HEAD request for the part specified. Useful querying about the size of the part and the number of parts in this object.
expected_bucket_owner No The account ID of the expected bucket owner. If the account ID that you provide does not match the actual owner of the bucket, the request fails with the HTTP status code 403 Forbidden (access denied).
checksum_mode No To retrieve the checksum, this parameter must be enabled. General purpose buckets - If you enable checksum mode and the object is uploaded with a checksum and encrypted with an Key Management Service (KMS) key, you must have permission to use the kms:Decrypt action to retrieve the checksum. Directory buckets - If you enable ChecksumMode and the object is encrypted with Amazon Web Services Key...

Output

HeadObjectOutput.

Read-only native attributes, accessed as response.field. Collection getters materialize Python values; to_dict() recursively materializes a mapping. Streams are consumed once.

Field Type Presence References
delete_marker bool | None Always present —
accept_ranges str | None Always present —
expiration str | None Always present —
restore str | None Always present —
archive_status ArchiveStatusOutput | None Always present ArchiveStatusOutput
last_modified str | None Always present —
content_length int | None Always present —
checksum_crc32 str | None Always present —
checksum_crc32_c str | None Always present —
checksum_crc64_nvme str | None Always present —
checksum_sha1 str | None Always present —
checksum_sha256 str | None Always present —
checksum_sha512 str | None Always present —
checksum_md5 str | None Always present —
checksum_xxhash64 str | None Always present —
checksum_xxhash3 str | None Always present —
checksum_xxhash128 str | None Always present —
checksum_type ChecksumTypeOutput | None Always present ChecksumTypeOutput
e_tag str | None Always present —
missing_meta int | None Always present —
version_id str | None Always present —
cache_control str | None Always present —
content_disposition str | None Always present —
content_encoding str | None Always present —
content_language str | None Always present —
content_type str | None Always present —
content_range str | None Always present —
website_redirect_location str | None Always present —
server_side_encryption ServerSideEncryptionOutput | None Always present ServerSideEncryptionOutput
metadata dict[str, str] | None Always present —
sse_customer_algorithm str | None Always present —
sse_customer_key_md5 str | None Always present —
ssekms_key_id str | None Always present —
bucket_key_enabled bool | None Always present —
storage_class StorageClassOutput | None Always present StorageClassOutput
request_charged RequestChargedOutput | None Always present RequestChargedOutput
replication_status ReplicationStatusOutput | None Always present ReplicationStatusOutput
parts_count int | None Always present —
tag_count int | None Always present —
object_lock_mode ObjectLockModeOutput | None Always present ObjectLockModeOutput
object_lock_retain_until_date str | None Always present —
object_lock_legal_hold_status ObjectLockLegalHoldStatusOutput | None Always present ObjectLockLegalHoldStatusOutput
object_lock_event_hold ObjectLockEventHoldOutput | None Always present ObjectLockEventHoldOutput
object_lock_event_hold_duration_days int | None Always present —
object_lock_event_hold_duration_years int | None Always present —
expires str | None Always present —
expires_string str | None Always present —

| None means a value can be absent. Output mappings include every declared key; optional input keys may be omitted. Unknown output enum/union variants are not automatically valid inputs.

ChecksumMode, HeadObjectOutput, RequestPayer

Follow these links for nested inputs and outputs; recursive types link back to the same type page.

Pagination and streaming

No generated paginator for this operation.

No output stream.

Waiters

from rboto import WaiterConfig. Calls use this public operation, including configured middleware and native retries. Polling, deadlines and errors.

client.waiters.object_exists:

async def object_exists(
    *,
    bucket: str,
    key: str,
    if_match: str | None = None,
    if_modified_since: str | None = None,
    if_none_match: str | None = None,
    if_unmodified_since: str | None = None,
    range: str | None = None,
    response_cache_control: str | None = None,
    response_content_disposition: str | None = None,
    response_content_encoding: str | None = None,
    response_content_language: str | None = None,
    response_content_type: str | None = None,
    response_expires: str | None = None,
    version_id: str | None = None,
    sse_customer_algorithm: str | None = None,
    sse_customer_key: str | None = None,
    sse_customer_key_md5: str | None = None,
    request_payer: RequestPayer | None = None,
    part_number: int | None = None,
    expected_bucket_owner: str | None = None,
    checksum_mode: ChecksumMode | None = None,
    waiter_config: WaiterConfig | None = None,
) -> HeadObjectOutput: ...

Default fixed delay: 5 seconds. Default maximum: 40 polls. No overall timeout unless configured.

Returns the successful polling Output.

Acceptor index State Matcher Model path Expected
0 success success — True
1 retry errorType — NotFound

Acceptors are checked in order. Missing fields or unmatched successful responses continue polling. Unmatched service errors propagate.

client.waiters.object_not_exists:

async def object_not_exists(
    *,
    bucket: str,
    key: str,
    if_match: str | None = None,
    if_modified_since: str | None = None,
    if_none_match: str | None = None,
    if_unmodified_since: str | None = None,
    range: str | None = None,
    response_cache_control: str | None = None,
    response_content_disposition: str | None = None,
    response_content_encoding: str | None = None,
    response_content_language: str | None = None,
    response_content_type: str | None = None,
    response_expires: str | None = None,
    version_id: str | None = None,
    sse_customer_algorithm: str | None = None,
    sse_customer_key: str | None = None,
    sse_customer_key_md5: str | None = None,
    request_payer: RequestPayer | None = None,
    part_number: int | None = None,
    expected_bucket_owner: str | None = None,
    checksum_mode: ChecksumMode | None = None,
    waiter_config: WaiterConfig | None = None,
) -> None: ...

Default fixed delay: 5 seconds. Default maximum: 40 polls. No overall timeout unless configured.

Returns None when the modeled error confirms success.

Acceptor index State Matcher Model path Expected
0 success errorType — NotFound

Acceptors are checked in order. Missing fields or unmatched successful responses continue polling. Unmatched service errors propagate.

Errors

Import from rboto_s3.exceptions:

NotFoundError.

Other service failures use the service base error; credential, transport and timeout failures use shared errors.

Service guide · Pinned model