• Object Storage Service

obs
  1. Help Center
  2. Object Storage Service
  3. API Reference (OBS)
  4. Operations on Objects
  5. PUT Object - Copy
  6. Requests

Requests

Syntax

 PUT /destinationObjectName HTTP/1.1 
 User-Agent: agent
 Host: bucketname.obs.example.com 
 Accept: */*
 x-amz-copy-source: /sourceBucket/sourceObject 
 x-amz-metadata-directive: COPY 
 x-amz-copy-source-if-match: etag 
 x-amz-copy-source-if-none-match: etag 
 x-amz-copy-source-if-unmodified-since: time_stamp 
 x-amz-copy-source-if-modified-since: time_stamp 
 Authorization: signatureValue 
 Date: date

Request Parameters

This request involves no parameters.

Request Headers

This request uses common headers. For details about common request headers, see section Common Request Headers. In addition, you can add optional headers to specify the object to be copied. Table 1 describes the optional headers.

Table 1 Optional request headers

Header

Description

Remarks

x-amz-acl

Indicates the ACL applied to the copy object. Possible values are privatepublic-readpublic-read-writeauthenticated-readbucket-owner-read, and bucket-owner-full-control.

Type: String

Example:

x-amz-acl: acl

Optional

x-amz-copy-source

Indicates the name of the source bucket and the key of the source object. If the source object has multiple version IDs, versionId is used to specify the required version ID.

Type: String

Example: x-amz-copy-source: /source_bucket/sourceObject

Mandatory

x-amz-metadata-directive

Indicates whether the metadata is copied from the source object or replaced with the metadata provided in the request.

Type: String

Valid values: COPY or REPLACE

Default: COPY

Example: x-amz-metadata-directive: COPY

Constraints:

  • If the value is neither COPY nor REPLACE, OBS returns status code 400.
  • If you want to copy an object to itself, set the value to REPLACE. Otherwise, OBS considers the request invalid and returns status code 400.

Optional

x-amz-copy-source-if-match

Copies the source object only if its ETag matches the one specified by this header, otherwise a 412 HTTP status code error (failed precondition) is returned.

Type: String

Example: x-amz-copy-source-if-match: etag

Constraints: This header can be used with x-amz-copy-source-if-unmodified-since but cannot be used with other conditional copy headers.

Optional

x-amz-copy-source-if-none-match

Copies the source object only if its ETag is different from the one specified by this header, otherwise a 412 HTTP status code error (failed precondition) is returned.

Type: String

Example: x-amz-copy-source-if-none-match: etag

Optional

x-amz-copy-source-if-unmodified-since

Copies the source object only if it has not been modified since the time specified by this header, otherwise a 412 HTTP status code error (failed precondition) is returned.

Type: HTTP time string complying with the format specified in http://www.ietf.org/rfc/rfc2616.txt.

Example: x-amz-copy-source-if-unmodified-since: time-stamp

Constraints: This header can be used with x-amz-copy-source-if-match but cannot be used with other conditional copy headers.

Optional

x-amz-copy-source-if-modified-since

Copies the source object only if it has not been modified since the time specified by this header, otherwise a 412 HTTP status code error (failed precondition) is returned.

Type: HTTP time string complying with the format specified in http://www.ietf.org/rfc/rfc2616.txt.

Example: x-amz-copy-source-if-modified-since: time-stamp

Constraints: This header can be used with x-amz-copy-source-if-none-match but cannot be used with other conditional copy headers.

Optional

x-amz-storage-class

When creating an object, you can add this header in the request to set the storage class of the object. If you do not add this header, the object will use the default storage class of the bucket.

Type: String

Note: The storage class can be STANDARD (OBS Standard), STANDARD_IA (OBS Warm), or GLACIER (OBS Cold). Note that the three storage class values are case-sensitive.

Example: x-amz-storage-class: STANDARD

Optional

x-amz-website-redirect-location

If a bucket is configured as a website, redirects requests for this object to another object in the same bucket or to an external URL. OBS stores the value of this header in the object metadata.

Type: String

Default: None

Constraint: The value must be prefixed by a slash (/), http://, or https://. The length of the value cannot exceed 2 K.

Optional

x-amz-server-side-encryption

Indicates the SSE-KMS mode. The destination object uses SSE-KMS for encryption.

Type: string

Example: x-amz-server-side-encryption:aws:kms

No. This header is mandatory when SSE-KMS is used.

x-amz-server-side-encryption-aws-kms-key-id

Indicates the master key ID. This header is used in SSE-KMS mode. If the customer does not provide the master key, the default master key will be used.

Type: string

Example: x-amz-server-side-encryption-aws-kms-key-id:arn:aws:kms:sichuan:domainiddomainiddomainiddoma0001:key/4f1cd4de-ab64-4807-920a-47fc42e7f0d0

No

x-amz-server-side-encryption-customer-algorithm

Indicates an encryption algorithm. The header is used in SSE-C mode.

Type: string

Example: x-amz-server-side-encryption-customer-algorithm:AES256

Constraints: This header must be used together with x-amz-server-side-encryption-customer-key and x-amz-server-side-encryption-customer-key-MD5.

No. This parameter is mandatory when SSE-C is used.

x-amz-server-side-encryption-customer-key

Indicates a key used to encrypt destination objects. The header is used in SSE-C mode.

Type: string

Example: x-amz-server-side-encryption-customer-key:K7QkYpBkM5+hcs27fsNkUnNVaobncnLht/rCB2o/9Cw=

Constraints: This header is a base64-encoded 256-bit or 512-bit key and must be used together with x-amz-server-side-encryption-customer-algorithm and x-amz-server-side-encryption-customer-key-MD5.

No. This header is mandatory when SSE-C is used.

x-amz-server-side-encryption-customer-key-MD5

Indicates the MD5 value of a key used to encrypt objects. The header is used in SSE-C mode. The MD5 value is used to check whether any error occurs during the transmission of the key.

Type: string

Example: x-amz-server-side-encryption-customer-key-MD5:4XvB3tbNTN+tIEVa0/fGaQ==

Constraints: This header is a base64-encoded 128-bit MD5 value and must be used together with x-amz-server-side-encryption-customer-algorithm and x-amz-server-side-encryption-customer-key.

No. This header is mandatory when SSE-C is used.

x-amz-copy-source-server-side-encryption-customer-algorithm

Indicates the algorithm used to decrypt a source object. The header is used in SSE-C mode.

Type: string

Example: x-amz-copy-source-server-side-encryption-customer-algorithm:AES256

Constraints: This header must be used together with x-amz-copy-source-server-side-encryption-customer-key and x-amz-copy-source-server-side-encryption-customer-key-MD5.

No. This header is mandatory when SSE-C is used to copy a source object.

x-amz-copy-source-server-side-encryption-customer-key

Indicates the key used to decrypt a source object. The header is used in SSE-C mode.

Type: string

Example: x-amz-copy-source-server-side-encryption-customer-key:K7QkYpBkM5+hcs27fsNkUnNVaobncnLht/rCB2o/9Cw=

Constraints: This header is a base64-encoded 256-bit or 512-bit key and must be used together with x-amz-copy-source-server-side-encryption-customer-algorithm and x-amz-copy-source-server-side-encryption-customer-key-MD5.

No. This header is mandatory when SSE-C is used to copy a source object.

x-amz-copy-source-server-side-encryption-customer-key-MD5

Indicates the MD5 value of the key used to decrypt a source object. The header is used in SSE-C mode. The MD5 value is used to check whether any error occurs during the transmission of the key.

Type: string

Example: x-amz-copy-source-server-side-encryption-customer-key-MD5:4XvB3tbNTN+tIEVa0/fGaQ==

Constraints: This header is a base64-encoded 128-bit MD5 value and must be used together with x-amz-copy-source-server-side-encryption-customer-algorithm and x-amz-copy-source-server-side-encryption-customer-key.

No. This header is mandatory when SSE-C is used to copy a source object.

x-amz-security-token

Header field used to identify the request of a federated user. When the federal authentication function is enabled, users sending such requests are identified as federated users.

Type: string

Optional. This parameter must be carried in the request sent by federated users.

For details about other headers, see section Common Request Headers.

Request Elements

This request involves no elements.