AWS SDK for .NET Documentation
CopyObject Method (request)
AmazonAmazon.S3AmazonS3ClientCopyObject(CopyObjectRequest) Did this page help you?   Yes   No    Tell us about it...
Creates a copy of an object that is already stored in Amazon S3.
Declaration Syntax
C#
public CopyObjectResponse CopyObject(
	CopyObjectRequest request
)
Parameters
request (CopyObjectRequest)
The CopyObjectRequest that defines the parameters of the operation.
Return Value
Returns a CopyObjectResponse from S3.
Remarks

When copying an object, you can preserve all metadata (default) or specify new metadata. However, the ACL is not preserved and is set to private for the user making the request. To override the default ACL setting, specify a new ACL when generating a copy request.

If versioning has been enabled on the source bucket, and you want to copy a specific version of an object, please use SourceVersionId to specify the version. By default, the most recent version of an object is copied to the destination bucket.

If Versioning has been enabled on the target bucket, S3 generates a unique version ID for the object being copied. This version ID is different from the version ID of the source object. Additionally, S3 returns the version ID of the copied object in the x-amz-version-id response header in the response. If you do not enable Versioning or suspend it on the target bucket, the version ID S3 generates is always the string literal - "null".

Examples

This example shows how to copy an object from one bucket/key to a different bucket/key.

CopyCopyObject sample
// Create a client
AmazonS3Client client = new AmazonS3Client();

// Create a CopyObject request
CopyObjectRequest request = new CopyObjectRequest
{
    SourceBucket = "SampleBucket",
    SourceKey = "Item1",
    DestinationBucket = "AnotherBucket",
    DestinationKey = "Copy1",
    CannedACL = S3CannedACL.PublicRead
};

// Issue request
client.CopyObject(request);
Exceptions
See Also

Assembly: AWSSDK (Module: AWSSDK) Version: 1.5.60.0 (1.5.60.0)