Skip to main content

CopyObject

Description

CopyObject is used to copy objects within the same bucket or between different buckets in the same region.

Request Method

POST

Request Path

/apsara/route/OneRouter/CopyObject

Request Parameters Common Parameters

NameLocationTypeRequiredSample valueDescription
x-oss-metadata-directiveBODYstringNoCOPYspecifies how to set the meta information of the target object. The values are as follows: COPY (default): Copy the metadata of the source Object to the target Object. OSS will not copy the of the source Object x-oss-server-side-encryption The property is configured to the target Object. The server-side encryption encoding method of the target object depends on whether is specified for the current copy operation. x-oss-server-side-encryption . REPLACE: Ignore the metadata of the source Object and directly use the metadata specified in the request.
x-oss-server-side-encryptionBODYstringNoAES256specifies the server-side entropy encoding encryption algorithm when OSS creates the target object. values: AES256 , KMS if the copy operation is not specified x-oss-server-side-encryption , no matter whether the source object has been encrypted or encoded on the server side, the copied target object will not be encrypted or encoded on the server side. If is specified in the copy operation x-oss-server-side-encryption , regardless of whether the source object has been encrypted or encoded on the server side, the copied target object will be encrypted and encoded on the server side. And the response header of the copy operation will contain x-oss-server-side-encryption , the value is the encryption algorithm of the target object. When the target object is downloaded, the response header also contains x-oss-server-side-encryption , the value is the encryption algorithm of the object.
versionBODYstringNo2016-01-01version of api
x-oss-copy-sourceBODYstringYes/oss-example/oss.jpgspecifies the source address of the copy. Default value: None
x-oss-copy-source-if-unmodified-sinceBODYstringNo2019-04-09T07:01:56.000Zif the specified time is equal to or later than the actual modification time of the file, the file is copied normally and 200 OK is returned; Otherwise, the 412 Precondition Failed error code (preprocessing failed) is returned. Default value: None
x-oss-taggingBODYstringNoa:1specifies the object label of the object. multiple labels can be set at the same time, for example: TagA = A & amp;TagB = B. indicates that Key and Value require advanced URL encoding. if an item does not have "=", Value is regarded as a null character.
x-oss-object-aclBODYstringNoprivateSpecify the access permission when OSS creates the target object. Value: public-read, private, public-read-write, default.
x-oss-tagging-directiveBODYstringNoCopyspecifies how to set the object label of the target object. The values are as follows: Copy (default): Copy the object label of the source object to the target object. Replace: the object label of the source object is ignored, and the object label specified in the request is directly used.
regionIdBODYstringYesNo sample value for this parameter.region id
x-oss-copy-source-if-none-matchBODYstringNo5B3C1A2E053D763E1B002CC607C5****if the ETag value of the source object is not equal to the ETag value you provided, the copy operation is performed and 200 OK is returned; Otherwise, the 304 Not Modified error code (preprocessing failed) is returned. Default value: None
x-oss-copy-source-if-matchBODYstringNo5B3C1A2E053D763E1B002CC607C5****if the ETag value of the source object is equal to the ETag value provided by you, the copy operation is performed and 200 OK is returned; Otherwise, the 412 Precondition Failed error code (preprocessing failed) is returned. Default value: None
x-oss-copy-source-if-modified-sinceBODYstringNo2019-04-09T07:01:56.000Zif the source object has been modified after the time specified by the user, the copy operation is performed; Otherwise, 304 Not Modified error code (preprocessing failed) is returned. Default value: None
x-oss-server-side-encryption-key-idBODYstringNo9468da86-3509-4f8d-a61e-6eab1eac****indicates the user master key hosted by KMS. This parameter is only available in x-oss-server-side-encryption is valid for KMS.

Return data

NameTypeSample valueDescription
LastModifiedstringFri, 24 Feb 2012 07:18:48 GMTthe last update time of the target object. parent element: CopyObjectResult
ETagstring5B3C1A2E053D763E1B002CC607C5****the ETag value of the target object. parent element: CopyObjectResult
CopyObjectResultcontainernot involvedCopyObject result. Default value: None

Example

Successful Response example

{
"LastModified":"Fri,
24 Feb 2012 07:18:48 GMT",
"ETag":"5B3C1A2E053D763E1B002CC607C5****",
"CopyObjectResult":"not involved"
}

Failed Response example

{
"errorSample":
{
"resultCode":-1,
"resultMsg":"system error",
"result":null
}

}