S3Client.get_object
rboto-s3==0.4.0 · Service index · Types
Model summary (excerpt): Retrieves an object from Amazon S3. In the GetObject request, specify the full key name for the object. General purpose buckets - Both the virtual-hosted-style requests and the path-style requests are supported. For a virtual hosted-style request example, if you have the object photos/2006/February/sample.jpg , specify the object key name as /photos/2006/February/sample.jpg . For a path-style...
Install and imports
from rboto import S3Client
from rboto_s3.types import (
ChecksumMode,
GetObjectOutput,
RequestPayer,
)
Signature
async def get_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,
) -> GetObjectOutput: ...
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 bucket name containing 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 follow the... |
key |
Yes | Key of the object to get. |
if_match |
No | Return the object only if its entity tag (ETag) is the same as the one specified in this header; 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, 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, S3 returns 304 Not Modified status code. For more information about... |
if_none_match |
No | Return the object only if its entity tag (ETag) is different from the one specified in this header; 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, S3 returns 304 Not Modified HTTP status code. For... |
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, S3 returns 200 OK and the data requested. For more information about... |
range |
No | Downloads the specified byte range of an object. For more information about the HTTP Range header, see https://www.rfc-editor.org/rfc/rfc9110.html#name-range . Amazon S3 doesn't support retrieving multiple ranges of data per GET request. |
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. By default, the GetObject operation returns the current version of an object. To return a different version, use the versionId subresource. If you include a versionId in your request header, you must have the s3:GetObjectVersion permission to access a specific version of an object. The s3:GetObject permission is not required in... |
sse_customer_algorithm |
No | Specifies the algorithm to use when decrypting the object (for example, AES256 ). If you encrypt an object by using server-side encryption with customer-provided encryption keys (SSE-C) when you store the object in Amazon S3, then when you GET the object, you must use the following headers: x-amz-server-side-encryption-customer-algorithm x-amz-server-side-encryption-customer-key... |
sse_customer_key |
No | Specifies the customer-provided encryption key that you originally provided for Amazon S3 to encrypt the data before storing it. This value is used to decrypt the object when recovering it and must match the one used when storing the data. The key must be appropriate for use with the algorithm specified in the x-amz-server-side-encryption-customer-algorithm header. If you encrypt an object by... |
sse_customer_key_md5 |
No | Specifies the 128-bit MD5 digest of the customer-provided 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. If you encrypt an object by using server-side encryption with customer-provided encryption keys (SSE-C) when you store the object in Amazon S3, then when you GET the object, you... |
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' GET request for the part specified. Useful for downloading just a part of an 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 mode must be enabled. |
Output
GetObjectOutput.
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 |
|---|---|---|---|
body |
ByteStream |
Always present | ByteStream |
delete_marker |
bool | None |
Always present | — |
accept_ranges |
str | None |
Always present | — |
expiration |
str | None |
Always present | — |
restore |
str | None |
Always present | — |
last_modified |
str | None |
Always present | — |
content_length |
int | None |
Always present | — |
e_tag |
str | 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 |
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_range |
str | None |
Always present | — |
content_type |
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.
Related types
ChecksumMode, GetObjectOutput, 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.
Output streams: ByteStream.
Consume with async for. Do not reuse a consumed stream.
ByteStream.read() buffers the complete body.
Errors
Import from rboto_s3.exceptions:
InvalidObjectStateError, NoSuchKeyError.
Other service failures use the service base error; credential, transport and timeout failures use shared errors.
Example
Complete, type-checked service example. Replace its placeholders and configure credentials before running it.
import asyncio
from rboto import S3Client
from rboto_s3.exceptions import NoSuchKeyError
async def main() -> None:
client = S3Client(region="us-east-1")
try:
response = await client.get_object(bucket="my-bucket", key="hello.txt")
except NoSuchKeyError:
print("Object does not exist")
return
# Buffer this small text object. Use async iteration for large bodies.
body: bytes = await response.body.read()
print(body.decode("utf-8"))
if __name__ == "__main__":
asyncio.run(main())