Object / Action / copy
copy¶
- S3.Object.copy(CopySource, ExtraArgs=None, Callback=None, SourceClient=None, Config=None)¶
Copy an object from one S3 location to this object.
This is a managed transfer which will perform a multipart copy in multiple threads if necessary.
Usage:
import boto3 s3 = boto3.resource('s3') copy_source = { 'Bucket': 'amzn-s3-demo-bucket1', 'Key': 'mykey' } bucket = s3.Bucket('amzn-s3-demo-bucket2') obj = bucket.Object('otherkey') obj.copy(copy_source)
- Parameters:
CopySource (dict) – The name of the source bucket, key name of the source object, and optional version ID of the source object. The dictionary format is:
{'Bucket': 'bucket', 'Key': 'key', 'VersionId': 'id'}. Note that theVersionIdkey is optional and may be omitted.ExtraArgs (dict) – Extra arguments that may be passed to the client operation. For allowed copy arguments see
boto3.s3.transfer.S3Transfer.ALLOWED_COPY_ARGS.Callback (function) – A method which takes a number of bytes transferred to be periodically called during the copy.
SourceClient (botocore or boto3 Client) – The client to be used for operations that may happen at the source object. For example, this client is used for the head_object that determines the size of the copy. If no client is provided, the current client is used as the client for the source object. The current client still requires IAM permissions to access both buckets.
Config (boto3.s3.transfer.TransferConfig) – The transfer configuration to be used when performing the copy.