Skip to content

S3Client.copy_object

rboto-s3==0.4.0 · Service index · Types

Model summary (excerpt): Creates a copy of an object that is already stored in Amazon S3. 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...

Install and imports

python -m pip install "rboto[s3]==0.4.0"
from rboto import S3Client
from rboto_s3.types import (
    AnnotationDirective,
    ChecksumAlgorithm,
    CopyObjectOutput,
    MetadataDirective,
    ObjectCannedACL,
    ObjectLockEventHold,
    ObjectLockLegalHoldStatus,
    ObjectLockMode,
    RequestPayer,
    ServerSideEncryption,
    StorageClass,
    TaggingDirective,
)

Signature

async def copy_object(
    *,
    bucket: str,
    copy_source: str,
    key: str,
    acl: ObjectCannedACL | None = None,
    cache_control: str | None = None,
    checksum_algorithm: ChecksumAlgorithm | None = None,
    content_disposition: str | None = None,
    content_encoding: str | None = None,
    content_language: str | None = None,
    content_type: str | None = None,
    copy_source_if_match: str | None = None,
    copy_source_if_modified_since: str | None = None,
    copy_source_if_none_match: str | None = None,
    copy_source_if_unmodified_since: str | None = None,
    expires: 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,
    if_match: str | None = None,
    if_none_match: str | None = None,
    metadata: dict[str, str] | None = None,
    metadata_directive: MetadataDirective | None = None,
    tagging_directive: TaggingDirective | None = None,
    annotation_directive: AnnotationDirective | 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,
    copy_source_sse_customer_algorithm: str | None = None,
    copy_source_sse_customer_key: str | None = None,
    copy_source_sse_customer_key_md5: str | 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,
    expected_source_bucket_owner: str | None = None,
) -> CopyObjectOutput: ...

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 destination bucket. 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 format...
copy_source Yes Specifies the source object for the copy operation. The source object can be up to 5 GB. If the source object is an object that was uploaded by using a multipart upload, the object copy will be a single part object after the source object is copied to the destination bucket. You specify the value of the copy source in one of two formats, depending on whether you want to access the source...
key Yes The key of the destination object.
acl No The canned access control list (ACL) to apply to the object. When you copy an object, the ACL metadata is not preserved and is set to private by default. Only the owner has full access control. To override the default ACL setting, specify a new ACL when you generate a copy request. For more information, see Using ACLs . If the destination bucket that you're copying objects to uses the bucket...
cache_control No Specifies the caching behavior along the request/reply chain.
checksum_algorithm No Indicates the algorithm that you want Amazon S3 to use to create the checksum for the object. For more information, see Checking object integrity in the Amazon S3 User Guide . When you copy an object, if the source object has a checksum, that checksum value will be copied to the new object by default. If the CopyObject request does not include this x-amz-checksum-algorithm header, the checksum...
content_disposition No Specifies presentational information for the object. Indicates whether an object should be displayed in a web browser or downloaded as a file. It allows specifying the desired filename for the downloaded file.
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 directory buckets, only the aws-chunked value is supported in this header field.
content_language No The language the content is in.
content_type No A standard MIME type that describes the format of the object data.
copy_source_if_match No Copies the object if its entity tag (ETag) matches the specified tag. If both the x-amz-copy-source-if-match and x-amz-copy-source-if-unmodified-since headers are present in the request and evaluate as follows, Amazon S3 returns 200 OK and copies the data: x-amz-copy-source-if-match condition evaluates to true x-amz-copy-source-if-unmodified-since condition evaluates to false
copy_source_if_modified_since No Copies the object if it has been modified since the specified time. If both the x-amz-copy-source-if-none-match and x-amz-copy-source-if-modified-since headers are present in the request and evaluate as follows, Amazon S3 returns the 412 Precondition Failed response code: x-amz-copy-source-if-none-match condition evaluates to false x-amz-copy-source-if-modified-since condition evaluates to true
copy_source_if_none_match No Copies the object if its entity tag (ETag) is different than the specified ETag. If both the x-amz-copy-source-if-none-match and x-amz-copy-source-if-modified-since headers are present in the request and evaluate as follows, Amazon S3 returns the 412 Precondition Failed response code: x-amz-copy-source-if-none-match condition evaluates to false x-amz-copy-source-if-modified-since condition...
copy_source_if_unmodified_since No Copies the object if it hasn't been modified since the specified time. If both the x-amz-copy-source-if-match and x-amz-copy-source-if-unmodified-since headers are present in the request and evaluate as follows, Amazon S3 returns 200 OK and copies the data: x-amz-copy-source-if-match condition evaluates to true x-amz-copy-source-if-unmodified-since condition evaluates to false
expires No The date and time at which the object is no longer cacheable.
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.
if_match No Copies the object if the entity tag (ETag) of the destination object matches the specified tag. If the ETag values do not match, the operation returns a 412 Precondition Failed error. If a concurrent 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. Expects the ETag value as a...
if_none_match No Copies the object only if the object key name at the destination does not already exist in the bucket specified. Otherwise, Amazon S3 returns a 412 Precondition Failed error. If a concurrent 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...
metadata No A map of metadata to store with the object in S3.
metadata_directive No Specifies whether the metadata is copied from the source object or replaced with metadata that's provided in the request. When copying an object, you can preserve all metadata (the default) or specify new metadata. If this header isn’t specified, COPY is the default behavior. General purpose bucket - For general purpose buckets, when you grant permissions, you can use the...
tagging_directive No Specifies whether the object tag-set is copied from the source object or replaced with the tag-set that's provided in the request. The default value is COPY . Directory buckets - For directory buckets in a CopyObject operation, only the empty tag-set is supported. Any requests that attempt to write non-empty tags into directory buckets will receive a 501 Not Implemented status code. When the...
annotation_directive No Specifies whether you want to copy annotations from the source object or exclude them. If this header isn't specified, COPY is the default behavior. Valid Values: COPY | EXCLUDE You can specify this directive as either an HTTP header ( x-amz-object-annotation-directive ) or as a query string parameter. Use the query string form when generating presigned URLs that need to control annotation...
server_side_encryption No The server-side encryption algorithm used when storing this object in Amazon S3. Unrecognized or unsupported values won’t write a destination object and will receive a 400 Bad Request response. Amazon S3 automatically encrypts all new objects that are copied to an S3 bucket. When copying an object, if you don't specify encryption information in your copy request, the encryption setting of the...
storage_class No If the x-amz-storage-class header is not used, the copied object will be stored in the STANDARD Storage Class by default. The STANDARD storage class provides high durability and high availability. Depending on performance needs, you can specify a different Storage Class. Directory buckets - Directory buckets only support EXPRESS_ONEZONE (the S3 Express One Zone storage class) in Availability...
website_redirect_location No If the destination bucket is configured as a website, redirects requests for this object copy to another object in the same bucket or to an external URL. Amazon S3 stores the value of this header in the object metadata. This value is unique to each object and is not copied when using the x-amz-metadata-directive header. Instead, you may opt to provide this header in combination with the...
sse_customer_algorithm No Specifies the algorithm to use when encrypting the object (for example, AES256 ). When you perform a CopyObject operation, if you want to use a different type of encryption setting for the target object, you can specify appropriate encryption-related headers to encrypt the target object with an Amazon S3 managed key, a KMS key, or a customer-provided key. If the encryption setting in your...
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 when the destination bucket is a...
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 when the destination bucket is a directory bucket.
ssekms_key_id No Specifies the KMS key ID (Key ID, Key ARN, or Key Alias) to use for object encryption. All GET and PUT requests for an object protected by KMS will fail if they're not made via SSL or using SigV4. For information about configuring any of the officially supported Amazon Web Services SDKs and Amazon Web Services CLI, see Specifying the Signature Version in Request Authentication in the Amazon S3...
ssekms_encryption_context No Specifies the Amazon Web Services KMS Encryption Context as an additional encryption context to use for the destination object encryption. The value of this header is a base64-encoded UTF-8 string holding JSON with the encryption context key-value pairs. General purpose buckets - This value must be explicitly added to specify encryption context for CopyObject requests if you want an additional...
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). If a target object uses SSE-KMS, you can enable an S3 Bucket Key for the object. Setting this header to true causes Amazon S3 to use an S3 Bucket Key for object encryption with SSE-KMS. Specifying this header with a COPY action doesn’t...
copy_source_sse_customer_algorithm No Specifies the algorithm to use when decrypting the source object (for example, AES256 ). If the source object for the copy is stored in Amazon S3 using SSE-C, you must provide the necessary encryption information in your request so that Amazon S3 can decrypt the object for copying. This functionality is not supported when the source object is in a directory bucket.
copy_source_sse_customer_key No Specifies the customer-provided encryption key for Amazon S3 to use to decrypt the source object. The encryption key provided in this header must be the same one that was used when the source object was created. If the source object for the copy is stored in Amazon S3 using SSE-C, you must provide the necessary encryption information in your request so that Amazon S3 can decrypt the object for...
copy_source_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. If the source object for the copy is stored in Amazon S3 using SSE-C, you must provide the necessary encryption information in your request so that Amazon S3 can decrypt the object for copying....
request_payer No
tagging No The tag-set for the object copy in the destination bucket. This value must be used in conjunction with the x-amz-tagging-directive if you choose REPLACE for the x-amz-tagging-directive . If you choose COPY for the x-amz-tagging-directive , you don't need to set the x-amz-tagging header, because the tag-set will be copied from the source object directly. The tag-set must be encoded as URL Query...
object_lock_mode No The Object Lock mode that you want to apply to the object copy. This functionality is not supported for directory buckets.
object_lock_retain_until_date No The date and time when you want the Object Lock of the object copy to expire. This functionality is not supported for directory buckets.
object_lock_legal_hold_status No Specifies whether you want to apply a legal hold to the object copy. This functionality is not supported for directory buckets.
object_lock_event_hold No The event hold status to apply to the object copy. Set to ON to enable or OFF to disable. This functionality is not supported for directory buckets.
object_lock_event_hold_duration_days No The event hold duration in days to apply to the object copy. 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 The event hold duration in years to apply to the object copy. 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 destination bucket owner. If the account ID that you provide does not match the actual owner of the destination bucket, the request fails with the HTTP status code 403 Forbidden (access denied).
expected_source_bucket_owner No The account ID of the expected source bucket owner. If the account ID that you provide does not match the actual owner of the source bucket, the request fails with the HTTP status code 403 Forbidden (access denied).

Output

CopyObjectOutput.

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
copy_object_result CopyObjectResultOutput | None Always present CopyObjectResultOutput
expiration str | None Always present —
copy_source_version_id str | None Always present —
version_id str | None Always present —
server_side_encryption ServerSideEncryptionOutput | None Always present ServerSideEncryptionOutput
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 —
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.

AnnotationDirective, ChecksumAlgorithm, CopyObjectOutput, MetadataDirective, ObjectCannedACL, ObjectLockEventHold, ObjectLockLegalHoldStatus, ObjectLockMode, RequestPayer, ServerSideEncryption, StorageClass, TaggingDirective

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.

Errors

Import from rboto_s3.exceptions:

ObjectNotInActiveTierError.

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

Service guide · Pinned model