Skip to content

S3Client.put_object

rboto-s3==0.4.0 · Service index · Types

Model summary (excerpt): End of support notice: As of October 1, 2025, Amazon S3 has discontinued support for Email Grantee Access Control Lists (ACLs). If you attempt to use an Email Grantee ACL in a request after October 1, 2025, the request will receive an HTTP 405 (Method Not Allowed) error. This change affects the following Amazon Web Services Regions: US East (N. Virginia), US West (N. California), US West...

Install and imports

python -m pip install "rboto[s3]==0.4.0"
from rboto import S3Client
from collections.abc import AsyncIterator
from rboto_s3.types import (
    ChecksumAlgorithm,
    ObjectCannedACL,
    ObjectLockEventHold,
    ObjectLockLegalHoldStatus,
    ObjectLockMode,
    PutObjectOutput,
    RequestPayer,
    ServerSideEncryption,
    StorageClass,
)

Signature

async def put_object(
    *,
    bucket: str,
    key: str,
    acl: ObjectCannedACL | None = None,
    body: bytes | _FileBody | AsyncIterator[bytes] | None = None,
    cache_control: str | None = None,
    content_disposition: str | None = None,
    content_encoding: str | None = None,
    content_language: str | None = None,
    content_length: int | None = None,
    content_md5: str | None = None,
    content_type: str | None = None,
    checksum_algorithm: ChecksumAlgorithm | None = None,
    checksum_crc32: str | None = None,
    checksum_crc32_c: str | None = None,
    checksum_crc64_nvme: str | None = None,
    checksum_sha1: str | None = None,
    checksum_sha256: str | None = None,
    checksum_sha512: str | None = None,
    checksum_md5: str | None = None,
    checksum_xxhash64: str | None = None,
    checksum_xxhash3: str | None = None,
    checksum_xxhash128: str | None = None,
    expires: str | None = None,
    if_match: str | None = None,
    if_none_match: str | None = None,
    grant_full_control: str | None = None,
    grant_read: str | None = None,
    grant_read_acp: str | None = None,
    grant_write_acp: str | None = None,
    write_offset_bytes: int | None = None,
    metadata: dict[str, str] | None = None,
    server_side_encryption: ServerSideEncryption | None = None,
    storage_class: StorageClass | None = None,
    website_redirect_location: str | None = None,
    sse_customer_algorithm: str | None = None,
    sse_customer_key: str | None = None,
    sse_customer_key_md5: str | None = None,
    ssekms_key_id: str | None = None,
    ssekms_encryption_context: str | None = None,
    bucket_key_enabled: bool | None = None,
    request_payer: RequestPayer | None = None,
    tagging: str | None = None,
    object_lock_mode: ObjectLockMode | None = None,
    object_lock_retain_until_date: str | None = None,
    object_lock_legal_hold_status: ObjectLockLegalHoldStatus | None = None,
    object_lock_event_hold: ObjectLockEventHold | None = None,
    object_lock_event_hold_duration_days: int | None = None,
    object_lock_event_hold_duration_years: int | None = None,
    expected_bucket_owner: str | None = None,
) -> PutObjectOutput: ...

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 to which the PUT action was initiated. 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 Object key for which the PUT action was initiated.
acl No The canned ACL to apply to the object. For more information, see Canned ACL in the Amazon S3 User Guide . When adding a new object, you can use headers to grant ACL-based permissions to individual Amazon Web Services accounts or to predefined groups defined by Amazon S3. These permissions are then added to the ACL on the object. By default, all objects are private. Only the owner has full...
body No Object data.
cache_control No Can be used to specify caching behavior along the request/reply chain. For more information, see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9 .
content_disposition No Specifies presentational information for the object. For more information, see https://www.rfc-editor.org/rfc/rfc6266#section-4 .
content_encoding No Specifies what content encodings have been applied to the object and thus what decoding mechanisms must be applied to obtain the media-type referenced by the Content-Type header field. For more information, see https://www.rfc-editor.org/rfc/rfc9110.html#field.content-encoding .
content_language No The language the content is in.
content_length No Size of the body in bytes. This parameter is useful when the size of the body cannot be determined automatically. For more information, see https://www.rfc-editor.org/rfc/rfc9110.html#name-content-length .
content_md5 No The Base64 encoded 128-bit MD5 digest of the message (without the headers) according to RFC 1864. This header can be used as a message integrity check to verify that the data is the same data that was originally sent. Although it is optional, we recommend using the Content-MD5 mechanism as an end-to-end integrity check. For more information about REST request authentication, see REST...
content_type No A standard MIME type describing the format of the contents. For more information, see https://www.rfc-editor.org/rfc/rfc9110.html#name-content-type .
checksum_algorithm No Indicates the algorithm used to create the checksum for the object when you use the SDK. This header will not provide any additional functionality if you don't use the SDK. When you send this header, there must be a corresponding x-amz-checksum- algorithm or x-amz-trailer header sent. Otherwise, Amazon S3 fails the request with the HTTP status code 400 Bad Request . For the x-amz-checksum-...
checksum_crc32 No This header can be used as a data integrity check to verify that the data received is the same data that was originally sent. This header specifies the Base64 encoded, 32-bit CRC32 checksum of the object. For more information, see Checking object integrity in the Amazon S3 User Guide .
checksum_crc32_c No This header can be used as a data integrity check to verify that the data received is the same data that was originally sent. This header specifies the Base64 encoded, 32-bit CRC32C checksum of the object. For more information, see Checking object integrity in the Amazon S3 User Guide .
checksum_crc64_nvme No This header can be used as a data integrity check to verify that the data received is the same data that was originally sent. This header specifies the Base64 encoded, 64-bit CRC64NVME checksum of the object. The CRC64NVME checksum is always a full object checksum. For more information, see Checking object integrity in the Amazon S3 User Guide .
checksum_sha1 No This header can be used as a data integrity check to verify that the data received is the same data that was originally sent. This header specifies the Base64 encoded, 160-bit SHA1 digest of the object. For more information, see Checking object integrity in the Amazon S3 User Guide .
checksum_sha256 No This header can be used as a data integrity check to verify that the data received is the same data that was originally sent. This header specifies the Base64 encoded, 256-bit SHA256 digest of the object. For more information, see Checking object integrity in the Amazon S3 User Guide .
checksum_sha512 No This header can be used as a data integrity check to verify that the data received is the same data that was originally sent. This header specifies the Base64 encoded, 512-bit SHA512 digest of the object. For more information, see Checking object integrity in the Amazon S3 User Guide .
checksum_md5 No This header can be used as a data integrity check to verify that the data received is the same data that was originally sent. This header specifies the Base64 encoded, 128-bit MD5 digest of the object. For more information, see Checking object integrity in the Amazon S3 User Guide .
checksum_xxhash64 No This header can be used as a data integrity check to verify that the data received is the same data that was originally sent. This header specifies the Base64 encoded, 64-bit XXHASH64 checksum of the object. For more information, see Checking object integrity in the Amazon S3 User Guide .
checksum_xxhash3 No This header can be used as a data integrity check to verify that the data received is the same data that was originally sent. This header specifies the Base64 encoded, 64-bit XXHASH3 checksum of the object. For more information, see Checking object integrity in the Amazon S3 User Guide .
checksum_xxhash128 No This header can be used as a data integrity check to verify that the data received is the same data that was originally sent. This header specifies the Base64 encoded, 128-bit XXHASH128 checksum of the object. For more information, see Checking object integrity in the Amazon S3 User Guide .
expires No The date and time at which the object is no longer cacheable. For more information, see https://www.rfc-editor.org/rfc/rfc7234#section-5.3 .
if_match No Uploads the object only if the ETag (entity tag) value provided during the WRITE operation matches the ETag of the object in S3. If the ETag values do not match, the operation returns a 412 Precondition Failed error. If a conflicting operation occurs during the upload S3 returns a 409 ConditionalRequestConflict response. On a 409 failure you should fetch the object's ETag and retry the upload....
if_none_match No Uploads the object only if the object key name does not already exist in the bucket specified. Otherwise, Amazon S3 returns a 412 Precondition Failed error. If a conflicting operation occurs during the upload S3 returns a 409 ConditionalRequestConflict response. On a 409 failure you should retry the upload. Expects the '*' (asterisk) character. For more information about conditional requests,...
grant_full_control No Gives the grantee READ, READ_ACP, and WRITE_ACP permissions on the object. This functionality is not supported for directory buckets. This functionality is not supported for Amazon S3 on Outposts.
grant_read No Allows grantee to read the object data and its metadata. This functionality is not supported for directory buckets. This functionality is not supported for Amazon S3 on Outposts.
grant_read_acp No Allows grantee to read the object ACL. This functionality is not supported for directory buckets. This functionality is not supported for Amazon S3 on Outposts.
grant_write_acp No Allows grantee to write the ACL for the applicable object. This functionality is not supported for directory buckets. This functionality is not supported for Amazon S3 on Outposts.
write_offset_bytes No Specifies the offset for appending data to existing objects in bytes. The offset must be equal to the size of the existing object being appended to. If no object exists, setting this header to 0 will create a new object. This functionality is only supported for objects in the Amazon S3 Express One Zone storage class in directory buckets.
metadata No A map of metadata to store with the object in S3.
server_side_encryption No The server-side encryption algorithm that was used when you store this object in Amazon S3 or Amazon FSx. General purpose buckets - You have four mutually exclusive options to protect data using server-side encryption in Amazon S3, depending on how you choose to manage the encryption keys. Specifically, the encryption key options are Amazon S3 managed keys (SSE-S3), Amazon Web Services KMS...
storage_class No By default, Amazon S3 uses the STANDARD Storage Class to store newly created objects. The STANDARD storage class provides high durability and high availability. Depending on performance needs, you can specify a different Storage Class. For more information, see Storage Classes in the Amazon S3 User Guide . Directory buckets only support EXPRESS_ONEZONE (the S3 Express One Zone storage class)...
website_redirect_location No If the bucket is configured as a website, redirects requests for this object to another object in the same bucket or to an external URL. Amazon S3 stores the value of this header in the object metadata. For information about object metadata, see Object Key and Metadata in the Amazon S3 User Guide . In the following example, the request header sets the redirect to an object (anotherPage.html)...
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.
ssekms_key_id No Specifies the KMS key ID (Key ID, Key ARN, or Key Alias) to use for object encryption. If the KMS key doesn't exist in the same account that's issuing the command, you must use the full Key ARN not the Key ID. General purpose buckets - If you specify x-amz-server-side-encryption with aws:kms or aws:kms:dsse , this header specifies the ID (Key ID, Key ARN, or Key Alias) of the KMS key to use....
ssekms_encryption_context No Specifies the Amazon Web Services KMS Encryption Context as an additional encryption context to use for object encryption. The value of this header is a Base64 encoded string of a UTF-8 encoded JSON, which contains the encryption context as key-value pairs. This value is stored as object metadata and automatically gets passed on to Amazon Web Services KMS for future GetObject operations on...
bucket_key_enabled No Specifies whether Amazon S3 should use an S3 Bucket Key for object encryption with server-side encryption using Key Management Service (KMS) keys (SSE-KMS). General purpose buckets - Setting this header to true causes Amazon S3 to use an S3 Bucket Key for object encryption with SSE-KMS. Also, specifying this header with a PUT action doesn't affect bucket-level settings for S3 Bucket Key....
request_payer No
tagging No The tag-set for the object. The tag-set must be encoded as URL Query parameters. (For example, "Key1=Value1") This functionality is not supported for directory buckets.
object_lock_mode No The Object Lock mode that you want to apply to this object. This functionality is not supported for directory buckets.
object_lock_retain_until_date No The date and time when you want this object's Object Lock to expire. Must be formatted as a timestamp parameter. This functionality is not supported for directory buckets.
object_lock_legal_hold_status No Specifies whether a legal hold will be applied to this object. For more information about S3 Object Lock, see Object Lock in the Amazon S3 User Guide . This functionality is not supported for directory buckets.
object_lock_event_hold No Specifies the event hold status to apply to this object. Set to ON to enable or OFF to disable. This functionality is not supported for directory buckets.
object_lock_event_hold_duration_days No Specifies the event hold duration in days to apply to this object. You cannot specify a duration in both days and years. This functionality is not supported for directory buckets.
object_lock_event_hold_duration_years No Specifies the event hold duration in years to apply to this object. You cannot specify a duration in both days and years. This functionality is not supported for directory buckets.
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).

Output

PutObjectOutput.

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
expiration str | 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
server_side_encryption ServerSideEncryptionOutput | None Always present ServerSideEncryptionOutput
version_id 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 —
ssekms_encryption_context str | None Always present —
bucket_key_enabled bool | None Always present —
size int | None Always present —
request_charged RequestChargedOutput | None Always present RequestChargedOutput

| 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.

ChecksumAlgorithm, ObjectCannedACL, ObjectLockEventHold, ObjectLockLegalHoldStatus, ObjectLockMode, PutObjectOutput, RequestPayer, ServerSideEncryption, StorageClass

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.

Input event streams accept the declared AsyncIterator of typed events.

Request byte bodies use bytes; they do not accept file objects or iterators.

Errors

Import from rboto_s3.exceptions:

EncryptionTypeMismatchError, InvalidRequestError, InvalidWriteOffsetError, TooManyPartsError.

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

Service guide · Pinned model