Yandex.Cloud
  • Services
  • Why Yandex.Cloud
  • Pricing
  • Documentation
  • Contact us
Get started
Yandex Object Storage
  • Getting started
  • Step-by-step instructions
    • All instructions
    • Buckets
      • Creating a bucket
      • Deleting a bucket
      • Limiting the maximum size of a bucket
      • Allowing public access to a bucket
      • Bucket encryption
      • Managing object lifecycles
      • Managing CORS configurations
      • Editing a bucket ACL
      • Logging actions with the bucket
    • Objects
      • Uploading an object
      • Getting information about an object
      • Downloading an object
      • Getting a public link to an object
      • Deleting an object
      • Deleting a partially uploaded object
      • Editing an object ACL
    • Static website hosting
      • Hosting setup
      • Support for your own domain
      • Support for multiple domain names
      • Configuring HTTPS
  • Concepts
    • Overview
    • Bucket
    • Objects
    • Bucket versioning
    • Object lifecycles
    • CORS
    • Static website hosting
    • Pre-signed URLs
    • Multipart upload
    • Access control lists (ACLs)
    • Bucket Policy
    • Upload file via HTML form
    • Storage class
    • Logging actions with a bucket
    • Backups
    • TLS protocol
    • Quotas and limits
  • Tools
    • All tools
    • Console clients
      • AWS CLI
      • S3cmd
    • File browsers
      • CyberDuck
      • WinSCP
    • SDK
      • AWS SDK for Java
      • Python SDK (boto)
    • FUSE
      • s3fs
      • goofys
  • Amazon S3-compatible HTTP API
    • How to use the API
    • Signing requests
    • API reference
      • All services and methods
      • Bucket
        • All methods
        • create
        • getBucketEncryption
        • getMeta
        • listObjects
        • listBuckets
        • deleteBucket
        • deleteBucketEncryption
        • putBucketEncryption
        • putBucketVersioning
        • getBucketVersioning
        • putBucketLogging
        • getBucketLogging
        • listObjectVersions
      • Object
        • All methods
        • upload
        • get
        • copy
        • getObjectMeta
        • delete
        • deleteMultipleObjects
        • options
      • Multipart upload
        • General multipart upload procedure
        • startUpload
        • uploadPart
        • copyPart
        • listParts
        • abortUpload
        • completeUpload
        • listUploads
      • Static Website Hosting
        • All methods
        • upload
        • get
        • delete
        • Static website response codes
      • CORS
        • All methods
        • XML structure of CORS configuration
        • upload
        • get
        • delete
      • Lifecycles
        • All methods
        • XML structure of lifecycle configuration
        • upload
        • get
        • delete
      • ACL
        • All methods
        • XML structure of ACL configuration
        • objectGetAcl
        • objectPutAcl
        • bucketGetAcl
        • bucketPutAcl
      • Bucket Policy
        • All methods
        • GetBucketPolicy
        • PutBucketPolicy
        • DeleteBucketPolicy
        • Data schema
        • Actions
        • Conditions
      • Common request headers
      • Common response headers
      • Responses
  • Access management
  • Pricing policy
    • Current pricing policy
    • Archive
      • Before January 1, 2019
      • From January 1 to March 1, 2019
  • Questions and answers
  1. Amazon S3-compatible HTTP API
  2. API reference
  3. Object
  4. copy

copy method

  • Request
    • Path parameters
    • Headers
  • Response
    • Headers
    • Response codes
    • Data schema

Creates a copy of an object stored in Object Storage. Objects up to 5 GB can be copied with a single copy operation. For objects larger than 5 GB, use the copyPart operation.

To specify the copy source, use the x-amz-copy-source header. The copy request must not pass any data other than headers.

Note

Object Storage does not lock an object for writing and can simultaneously accept multiple requests that copy objects to the same resulting object. After all the requests are completed, the resulting object is the one whose copy operation was run last.

The object metadata is copied along with the object. If necessary, you can change the metadata by explicitly setting the appropriate headers.

You can also use headers to:

  • Change an object's storage class.
  • Add conditions for copying an object.

The user must have permission to read the source object and write data to the resulting bucket.

Request

PUT /{bucket}/{key} HTTP/1.1

Path parameters

Parameter Description
bucket Name of the resulting bucket.
key Key of the resulting object. ID that the object is saved with in Object Storage.

Headers

Required headers are listed in the table below.

Header Description
x-amz-copy-source The name of the bucket and the key of the object to copy, separated by the / character.

For example, x-amz-copy-source: /source_bucket/sourceObject.

You should also use the necessary common request headers.

Use the headers from the table below if you need to change the default behavior of the copy method.

Header Description
x-amz-metadata-directive Metadata copy mode.

If the header value is COPY, the object metadata is copied and all the x-amz-meta-* headers are ignored. Default behavior of the copy method.

If the header value is REPLACE, the object metadata is replaced with the metadata specified in the request.

The x-amz-storage-class header is not copied; add it to the request if necessary.
x-amz-copy-source-if-match Object copying criteria.

If the ETag of an object is the same as in the header, the object is copied.

If the criteria isn't met, Object Storage returns a 412 error.

Can be used with the x-amz-copy-source-if-unmodified-since header.
x-amz-copy-source-if-none-match Object copying criteria.

If the ETag of the object isn't the same as in the header, the object is copied.

If the criteria isn't met, Object Storage returns a 412 error.

Can be used with the x-amz-copy-source-if-modified-since method.
x-amz-copy-source-if-unmodified-since Object copying criteria.

The object is copied if it didn't change since the specified time.

If the criteria isn't met, Object Storage returns a 412 error.

Can be used with the x-amz-copy-source-if-match header.
x-amz-copy-source-if-modified-since Object copying criteria.

The object is copied if it changed since the specified time.

If the criteria isn't met, Object Storage returns a 412 error.

Can be used with the x-amz-copy-source-if-none-match header.
x-amz-server-side-encryption Default encryption algorithm used for new objects.
x-amz-server-side-encryption-aws-kms-key-id ID of the KMS key used by default to encrypt new objects.
x-amz-storage-class Object storage class.

Possible values:
- STANDARD for uploading an object to standard storage.
- COLD, STANDARD_IA, and NEARLINE for uploading an object to cold storage.

If the header is omitted, the object is saved to the storage specified in the bucket settings.
x-amz-meta-* User-defined object metadata.

Object Storage considers all headers starting with x-amz-meta- as user-defined. It doesn't process these headers. Instead, it saves them in their original format.

The total size of user-defined headers must not exceed 2 KB. The size of user-defined data is determined as the length of the UTF-8 encoded string. Both the headers and their values are included in the size.

Headers that have x-amz-metadata-directive: COPY are ignored.

Response

Headers

A response may contain common response headers and the headers listed in the table below.

Header Description
x-amz-storage-class Object storage class.

Possible values:
- STANDARD for an object stored in standard storage.
- COLD for an object stored in cold storage.

Response codes

For a list of possible responses, see Responses.

Data schema

<CopyObjectResult>
   <LastModified>2019-02-15T14:32:00</LastModified>
   <ETag>"9bgh7535f2734ec974343yuc93985328"</ETag>
</CopyObjectResult>
Element Description
CopyObjectResult Contains response elements.

Path: /CopyObjectResult.
ETag ETag of the resulting object. Because metadata is not taken into account when calculating the ETag, the ETag of the source and resulting objects must match.

Path: /CopyObjectResult/ETag.
LastModified Date when the object was last modified.

Path: /CopyObjectResult/LastModified.
In this article:
  • Request
  • Path parameters
  • Headers
  • Response
  • Headers
  • Response codes
  • Data schema
Language
Careers
Privacy policy
Terms of use
© 2021 Yandex.Cloud LLC