public-read
(i.e., everyone has read permission for the object). Besides, you must have write permission for the destination bucket.HTTP 200 OK
will be returned with the error as the response body, meaning that the HTTP 200 OK
response can include both success and error information. When using this API, pay attention to the content of the response body to determine whether the copy request was successful and process the result accordingly.PUT Object - Copy
is equivalent to requesting GET Object
once in the source bucket and requesting PUT Object
once in the destination bucket. Please note that this operation will incur charges for items such as read and write requests, storage usage, cross-region replication traffic, and data processing and moderation generated by workflows.versionId
parameter in the x-cos-copy-source
request header to copy a specified version.PUT /<ObjectKey> HTTP/1.1Host: <BucketName-APPID>.cos.<Region>.myqcloud.comDate: GMT Datex-cos-copy-source: <SourceBucketName-SourceAPPID>.cos.<SourceRegion>.myqcloud.com/<SourceObjectKey>Content-Length: 0Authorization: Auth String
examplebucket-1250000000
(see Bucket Overview > Basic Information and Bucket Overview > Bucket Naming Conventions), and <Region> is a COS region (see Regions and Access Endpoints).Header | Description | Type | Required |
x-cos-copy-source | URL of the source object, where the object key needs to pass through URLEncode. The version of the source object can be specified by the versionId parameter, such as sourcebucket-1250000001.cos.ap-shanghai.myqcloud.com/example-%E8%85%BE%E8%AE%AF%E4%BA%91.jpg , or sourcebucket-1250000001.cos.ap-shanghai.myqcloud.com/example-%E8%85%BE%E8%AE%AF%E4%BA%91.jpg?versionId=MTg0NDUxNzYzMDc0NDMzNDExOTc | string | Yes |
x-cos-metadata-directive | Specifies whether to copy the metadata information of the source object. Enumerated values: Copy (default), Replaced .If this parameter is set to Copy , the metadata information of the source object will be copied. If this parameter is set to Replaced , the metadata information in the request header will be used as the metadata information of the destination object.If the destination and source objects are the same and you want to modify the metadata, this parameter must be set to Replaced . | Enum | No |
x-cos-copy-source-If-Modified-Since | If the object is modified after the specified time, the copy operation will be executed; otherwise, an HTTP 412 status code (Precondition Failed) is returned. | string | No |
x-cos-copy-source-If-Unmodified-Since | If the object is not modified after the specified time, the copy operation will be executed; otherwise, an HTTP 412 status code (Precondition Failed) is returned. | string | No |
x-cos-copy-source-If-Match | If the ETag of the object is the same as the specified value, the copy operation will be executed; otherwise, an HTTP 412 status code (Precondition Failed) is returned. | string | No |
x-cos-copy-source-If-None-Match | If the ETag of the object is not the same as the specified value, the copy operation will be executed; otherwise, an HTTP 412 status code (Precondition Failed) is returned. | string | No |
x-cos-storage-class | Storage class of the destination object. For the enumerated values, such as INTELLIGENT_TIERING , MAZ_INTELLIGENT_TIERING , STANDARD_IA , ARCHIVE , and DEEP_ARCHIVE , see Storage Class Overview. Default value: STANDARD . | Enum | No |
x-cos-tagging | A set of up to 10 object tags (for example, Key1=Value1&Key2=Value2 ). Tag key and tag value in the set must be URL-encoded. | string | No |
x-cos-tagging-directive | Specifies whether to copy the tags of the source object. Enumerated values: Copy (default), Replaced .If this parameter is set to Copy , tags of the source object will be copied.If this parameter is set to Replaced , tags specified in the request header will be used for the destination object.When the source and destination object is the same, that is, you want to modify the object tag, this parameter must be set to Replaced . | Enum | No |
x-cos-forbid-overwrite | For a bucket which has never enabled versioning, you may use it to specify whether to prohibit overwriting the object with the same name when uploading the object: When the x-cos-forbid-overwrite header is not specified or specified as false, the object with the same name will be overwritten by default; When the x-cos-forbid-overwrite is specified as true, overwriting the object with the same name will be prohibited. Note: For a bucket which has enabled versioning or suspended versioning, the x-cos-forbid-overwrite request header is invalid, which means overwriting objects with the same name is allowed whether the x-cos-forbid-overwrite request header is specified as true or false. | string | Not required |
x-cos-metadata-directive
must be set to Replaced
. Otherwise, the destination object cannot use the metadata information of the source object and the following headers cannot be specified.Header | Description | Type | Required |
Cache-Control | Cache directives as defined in RFC 2616. It will be stored as the object metadata. | string | No |
Content-Disposition | Filename as defined in RFC 2616. It will be stored as the object metadata. | string | No |
Content-Encoding | Encoding format as defined in RFC 2616. It will be stored as the object metadata. | string | No |
Content-Type | HTTP request content type (MIME) as defined in RFC 2616. This header describes the content type of the destination object and will be stored as the object metadata. Example: text/html , image/jpeg | string | Yes |
Expires | The cache expiration time as defined in RFC 2616. It will be stored as the object metadata. | string | No |
x-cos-meta-* | Contains the header and value of user-defined metadata. It will be stored as the metadata of the destination object. The maximum size is 2 KB. Example: For x-cos-meta-via: homepage , the header is x-cos-meta-via , the suffix is via , and the value is homepage .Note: The user-defined metadata value can contain underscores (_), whereas the headers support only hyphens (-) but not underscores. | string | No |
Header | Description | Type | Required |
x-cos-acl | Defines the ACL attribute of the destination object. For the enumerated values, such as default (default), private , and public-read , see the Preset ACL section in ACL Overview. Note: If you do not need to set an ACL for the object, set this parameter to default or leave it empty. In this way, the object will inherit the permissions of the bucket it is stored in. | Enum | No |
x-cos-grant-read | Grants a user permission to read the destination object in the format: id="[OwnerUin]" (e.g., id="100000000001" ). You can use a comma (,) to separate multiple users, for example, id="100000000001",id="100000000002" . | string | No |
x-cos-grant-read-acp | Grants a user permission to read the ACL of the destination object in the format: id="[OwnerUin]" (e.g., id="100000000001" ). You can use a comma (,) to separate multiple users, for example, id="100000000001",id="100000000002" . | string | No |
x-cos-grant-write-acp | Grants a user permission to write to the ACL of the destination object in the format: id="[OwnerUin]" (e.g., id="100000000001" ). You can use a comma (,) to separate multiple users, for example, id="100000000001",id="100000000002" . | string | No |
x-cos-grant-full-control | Grants a user full permission to operate on the destination object in the format: id="[OwnerUin]" (e.g., id="100000000001" ). You can use a comma (,) to separate multiple users, for example, id="100000000001",id="100000000002" . | string | No |
SSE-C
, you need to specify the following request headers to decrypt the source object:Header | Description | Type | Required |
x-cos-server-side-encryption-customer-algorithm | Server-side encryption algorithm. Currently, only AES256 is supported. | string | Required if the source object uses SSE-C. |
x-cos-server-side-encryption-customer-key | Base64-encoded server-side encryption key, such as MDEyMzQ1Njc4OUFCQ0RFRjAxMjM0NTY3ODlBQkNERUY= | string | Required if the source object uses SSE-C. |
x-cos-server-side-encryption-customer-key-MD5 | Base64-encoded MD5 hash of the server-side encryption key, such as U5L61r7jcwdNvT7frmUG8g== | string | Required if the source object uses SSE-C. |
Header | Description | Type |
x-cos-copy-source-version-id | Version ID of the source object | string |
<?xml version="1.0" encoding="UTF-8"?><CopyObjectResult><ETag>string</ETag><CRC64>number</CRC64><LastModified>date</LastModified><VersionId>string</VersionId></CopyObjectResult>
Node Name (Keyword) | Parent Node | Description | Type |
CopyObjectResult | None | Stores the result of PUT Object - Copy . | Container |
CopyObjectResult
:Node Name (Keyword) | Parent Node | Description | Type |
ETag | CopyObjectResult | Entity tag of the object. It indicates the content of the object when it is created and can be used to verify whether the object content is changed. Example: 8e0b617ca298a564c3331da28dcb50df The value of ETag is not necessarily the MD5 checksum of the object. The value will be different if the uploaded object is encrypted. | string |
CRC64 | CopyObjectResult | number | |
LastModified | CopyObjectResult | Last modified time of the object, in ISO 8601 format, such as 2019-05-24T10:56:40Z | date |
VersionId | CopyObjectResult | Version ID of the object. This node is returned only if versioning is enabled for the destination bucket. | string |
Transfer-Encoding: chunked
in the response by default. For readability, samples in this document are displayed without Transfer-Encoding
. During use, different languages and libraries can automatically process this encoding form. For more information, see the language- and library-related documents.PUT /exampleobject HTTP/1.1Host: destinationbucket-1250000000.cos.ap-beijing.myqcloud.comDate: Fri, 10 Apr 2020 18:20:30 GMTx-cos-copy-source: sourcebucket-1250000001.cos.ap-shanghai.myqcloud.com/example-%E8%85%BE%E8%AE%AF%E4%BA%91.jpgContent-Length: 0Authorization: q-sign-algorithm=sha1&q-ak=AKID8A0fBVtYFrNm02oY1g1JQQF0c3JO****&q-sign-time=1586542830;1586550030&q-key-time=1586542830;1586550030&q-header-list=content-length;date;host;x-cos-copy-source&q-url-param-list=&q-signature=f91b02809317616d993e14625996e416e08e****Connection: close
HTTP/1.1 200 OKContent-Type: application/xmlContent-Length: 219Connection: closeDate: Fri, 10 Apr 2020 18:20:30 GMTServer: tencent-cosx-cos-request-id: NWU5MGI4ZWVfNzljMDBiMDlfMWM3MjlfMWQ1****<?xml version="1.0" encoding="UTF-8"?><CopyObjectResult><ETag>"ee8de918d05640145b18f70f4c3aa602"</ETag><CRC64>16749565679157681890</CRC64><LastModified>2020-04-10T18:20:30Z</LastModified></CopyObjectResult>
PUT /exampleobject HTTP/1.1Host: destinationbucket-1250000000.cos.ap-beijing.myqcloud.comDate: Fri, 10 Apr 2020 18:20:41 GMTx-cos-metadata-directive: ReplacedContent-Type: application/octet-streamContent-Disposition: attachment; filename=example.jpgx-cos-copy-source: sourcebucket-1250000001.cos.ap-shanghai.myqcloud.com/example-%E8%85%BE%E8%AE%AF%E4%BA%91.jpgContent-Length: 0Authorization: q-sign-algorithm=sha1&q-ak=AKID8A0fBVtYFrNm02oY1g1JQQF0c3JO****&q-sign-time=1586542841;1586550041&q-key-time=1586542841;1586550041&q-header-list=content-disposition;content-length;content-type;date;host;x-cos-copy-source;x-cos-metadata-directive&q-url-param-list=&q-signature=aa2522c12b0ac82e29a812fca4334705cc96****Connection: close
HTTP/1.1 200 OKContent-Type: application/xmlContent-Length: 219Connection: closeDate: Fri, 10 Apr 2020 18:20:41 GMTServer: tencent-cosx-cos-request-id: NWU5MGI4ZjlfYTZjMDBiMDlfN2Y1YV8xYjI4****<?xml version="1.0" encoding="UTF-8"?><CopyObjectResult><ETag>"ee8de918d05640145b18f70f4c3aa602"</ETag><CRC64>16749565679157681890</CRC64><LastModified>2020-04-10T18:20:41Z</LastModified></CopyObjectResult>
PUT /exampleobject HTTP/1.1Host: examplebucket-1250000000.cos.ap-beijing.myqcloud.comDate: Fri, 10 Apr 2020 18:20:52 GMTx-cos-metadata-directive: ReplacedCache-Control: max-age=86400Content-Type: image/jpegx-cos-copy-source: examplebucket-1250000000.cos.ap-beijing.myqcloud.com/exampleobjectContent-Length: 0Authorization: q-sign-algorithm=sha1&q-ak=AKID8A0fBVtYFrNm02oY1g1JQQF0c3JO****&q-sign-time=1586542852;1586550052&q-key-time=1586542852;1586550052&q-header-list=cache-control;content-length;content-type;date;host;x-cos-copy-source;x-cos-metadata-directive&q-url-param-list=&q-signature=1bcab704e474e46359d97c8c1fbb93642069****Connection: close
HTTP/1.1 200 OKContent-Type: application/xmlContent-Length: 219Connection: closeDate: Fri, 10 Apr 2020 18:20:52 GMTServer: tencent-cosx-cos-request-id: NWU5MGI5MDRfNmRjMDJhMDlfZGNmYl8yMDVh****<?xml version="1.0" encoding="UTF-8"?><CopyObjectResult><ETag>"ee8de918d05640145b18f70f4c3aa602"</ETag><CRC64>16749565679157681890</CRC64><LastModified>2020-04-10T18:20:52Z</LastModified></CopyObjectResult>
PUT /exampleobject HTTP/1.1Host: examplebucket-1250000000.cos.ap-beijing.myqcloud.comDate: Fri, 10 Apr 2020 18:21:02 GMTx-cos-metadata-directive: Replacedx-cos-storage-class: ARCHIVEx-cos-copy-source: examplebucket-1250000000.cos.ap-beijing.myqcloud.com/exampleobjectContent-Length: 0Authorization: q-sign-algorithm=sha1&q-ak=AKID8A0fBVtYFrNm02oY1g1JQQF0c3JO****&q-sign-time=1586542862;1586550062&q-key-time=1586542862;1586550062&q-header-list=content-length;date;host;x-cos-copy-source;x-cos-metadata-directive;x-cos-storage-class&q-url-param-list=&q-signature=8726a359b342cb1cace6945812ee8379c3ad****Connection: close
HTTP/1.1 200 OKContent-Type: application/xmlContent-Length: 219Connection: closeDate: Fri, 10 Apr 2020 18:21:02 GMTServer: tencent-cosx-cos-request-id: NWU5MGI5MGVfN2RiNDBiMDlfMTk1MjhfMWZm****<?xml version="1.0" encoding="UTF-8"?><CopyObjectResult><ETag>"ee8de918d05640145b18f70f4c3aa602"</ETag><CRC64>16749565679157681890</CRC64><LastModified>2020-04-10T18:21:55Z</LastModified></CopyObjectResult>
PUT /exampleobject HTTP/1.1Host: destinationbucket-1250000000.cos.ap-beijing.myqcloud.comDate: Fri, 10 Apr 2020 18:21:12 GMTx-cos-server-side-encryption: AES256x-cos-copy-source: sourcebucket-1250000001.cos.ap-shanghai.myqcloud.com/example-%E8%85%BE%E8%AE%AF%E4%BA%91.jpgContent-Length: 0Authorization: q-sign-algorithm=sha1&q-ak=AKID8A0fBVtYFrNm02oY1g1JQQF0c3JO****&q-sign-time=1586542872;1586550072&q-key-time=1586542872;1586550072&q-header-list=content-length;date;host;x-cos-copy-source;x-cos-server-side-encryption&q-url-param-list=&q-signature=ee94ef60dfb512882b368be12c6d47526433****Connection: close
HTTP/1.1 200 OKContent-Type: application/xmlContent-Length: 219Connection: closeDate: Fri, 10 Apr 2020 18:21:13 GMTServer: tencent-cosx-cos-request-id: NWU5MGI5MTlfYmIwMmEwOV9hMmUxXzFkMDQ2****x-cos-server-side-encryption: AES256<?xml version="1.0" encoding="UTF-8"?><CopyObjectResult><ETag>"ee8de918d05640145b18f70f4c3aa602"</ETag><CRC64>16749565679157681890</CRC64><LastModified>2020-04-10T18:21:13Z</LastModified></CopyObjectResult>
PUT /exampleobject HTTP/1.1Host: destinationbucket-1250000000.cos.ap-beijing.myqcloud.comDate: Fri, 10 Apr 2020 18:21:23 GMTx-cos-server-side-encryption: cos/kmsx-cos-server-side-encryption-cos-kms-key-id: 48ba38aa-26c5-11ea-855c-52540085****x-cos-server-side-encryption-context: eyJhdXRob3IiOiJmeXNudGlhbiIsImNvbXBhbnkiOiJUZW5jZW50In0=x-cos-copy-source: sourcebucket-1250000001.cos.ap-shanghai.myqcloud.com/example-%E8%85%BE%E8%AE%AF%E4%BA%91.jpgContent-Length: 0Authorization: q-sign-algorithm=sha1&q-ak=AKID8A0fBVtYFrNm02oY1g1JQQF0c3JO****&q-sign-time=1586542883;1586550083&q-key-time=1586542883;1586550083&q-header-list=content-length;date;host;x-cos-copy-source;x-cos-server-side-encryption;x-cos-server-side-encryption-context;x-cos-server-side-encryption-cos-kms-key-id&q-url-param-list=&q-signature=28055a7cf07d7dde858fd924d6c0963b0c68****Connection: close
HTTP/1.1 200 OKContent-Type: application/xmlContent-Length: 219Connection: closeDate: Fri, 10 Apr 2020 18:21:23 GMTServer: tencent-cosx-cos-request-id: NWU5MGI5MjNfMTliOTJhMDlfMjRiYThfMTdk****x-cos-server-side-encryption: cos/kmsx-cos-server-side-encryption-cos-kms-key-id: 48ba38aa-26c5-11ea-855c-52540085****<?xml version="1.0" encoding="UTF-8"?><CopyObjectResult><ETag>"f69901ec9755a5defc29057e9ec69126"</ETag><CRC64>16749565679157681890</CRC64><LastModified>2020-04-10T18:22:16Z</LastModified></CopyObjectResult>
PUT /exampleobject HTTP/1.1Host: destinationbucket-1250000000.cos.ap-beijing.myqcloud.comDate: Fri, 10 Apr 2020 18:21:44 GMTx-cos-copy-source-server-side-encryption-customer-algorithm: AES256x-cos-copy-source-server-side-encryption-customer-key: MDEyMzQ1Njc4OUFCQ0RFRjAxMjM0NTY3ODlBQkNERUY=x-cos-copy-source-server-side-encryption-customer-key-MD5: U5L61r7jcwdNvT7frmUG8g==x-cos-server-side-encryption-customer-algorithm: AES256x-cos-server-side-encryption-customer-key: MDEyMzQ1Njc4OWFiY2RlZjAxMjM0NTY3ODlhYmNkZWY=x-cos-server-side-encryption-customer-key-MD5: hRasmdxgYDKV3nvbahU1MA==x-cos-copy-source: sourcebucket-1250000001.cos.ap-shanghai.myqcloud.com/example-%E8%85%BE%E8%AE%AF%E4%BA%91.jpgContent-Length: 0Authorization: q-sign-algorithm=sha1&q-ak=AKID8A0fBVtYFrNm02oY1g1JQQF0c3JO****&q-sign-time=1586542904;1586550104&q-key-time=1586542904;1586550104&q-header-list=content-length;date;host;x-cos-copy-source;x-cos-copy-source-server-side-encryption-customer-algorithm;x-cos-copy-source-server-side-encryption-customer-key;x-cos-copy-source-server-side-encryption-customer-key-md5;x-cos-server-side-encryption-customer-algorithm;x-cos-server-side-encryption-customer-key;x-cos-server-side-encryption-customer-key-md5&q-url-param-list=&q-signature=dece274320f748bb0c736b13e5409cd1c35f****Connection: close
HTTP/1.1 200 OKContent-Type: application/xmlContent-Length: 219Connection: closeDate: Fri, 10 Apr 2020 18:21:44 GMTServer: tencent-cosx-cos-request-id: NWU5MGI5MzhfZmFjODJhMDlfMTdlYzZfYmU1****x-cos-server-side-encryption-customer-algorithm: AES256x-cos-server-side-encryption-customer-key-MD5: hRasmdxgYDKV3nvbahU1MA==<?xml version="1.0" encoding="UTF-8"?><CopyObjectResult><ETag>"bf314b89d34119395d5610982d6581b1"</ETag><CRC64>16749565679157681890</CRC64><LastModified>2020-04-10T18:22:31Z</LastModified></CopyObjectResult>
PUT /exampleobject HTTP/1.1Host: examplebucket-1250000000.cos.ap-beijing.myqcloud.comDate: Fri, 10 Apr 2020 18:22:05 GMTx-cos-metadata-directive: Replacedx-cos-copy-source-server-side-encryption-customer-algorithm: AES256x-cos-copy-source-server-side-encryption-customer-key: MDEyMzQ1Njc4OUFCQ0RFRjAxMjM0NTY3ODlBQkNERUY=x-cos-copy-source-server-side-encryption-customer-key-MD5: U5L61r7jcwdNvT7frmUG8g==x-cos-copy-source: examplebucket-1250000000.cos.ap-beijing.myqcloud.com/exampleobjectContent-Length: 0Authorization: q-sign-algorithm=sha1&q-ak=AKID8A0fBVtYFrNm02oY1g1JQQF0c3JO****&q-sign-time=1586542925;1586550125&q-key-time=1586542925;1586550125&q-header-list=content-length;date;host;x-cos-copy-source;x-cos-copy-source-server-side-encryption-customer-algorithm;x-cos-copy-source-server-side-encryption-customer-key;x-cos-copy-source-server-side-encryption-customer-key-md5;x-cos-metadata-directive&q-url-param-list=&q-signature=b57bc8f6d666e9d722d30ad7d3ab442d9c43****Connection: close
HTTP/1.1 200 OKContent-Type: application/xmlContent-Length: 219Connection: closeDate: Fri, 10 Apr 2020 18:22:05 GMTServer: tencent-cosx-cos-request-id: NWU5MGI5NGRfOWFjOTJhMDlfMjg2NDdfMTA0****<?xml version="1.0" encoding="UTF-8"?><CopyObjectResult><ETag>"ee8de918d05640145b18f70f4c3aa602"</ETag><CRC64>16749565679157681890</CRC64><LastModified>2020-04-10T18:22:58Z</LastModified></CopyObjectResult>
PUT /exampleobject HTTP/1.1Host: destinationbucket-1250000000.cos.ap-beijing.myqcloud.comDate: Sat, 11 Apr 2020 17:51:35 GMTx-cos-copy-source: sourcebucket-1250000001.cos.ap-shanghai.myqcloud.com/example.jpg?versionId=MTg0NDUxNTc0NDYyMjQ2MzUzMjQContent-Length: 0Authorization: q-sign-algorithm=sha1&q-ak=AKID8A0fBVtYFrNm02oY1g1JQQF0c3JO****&q-sign-time=1586627495;1586634695&q-key-time=1586627495;1586634695&q-header-list=content-length;date;host;x-cos-copy-source&q-url-param-list=&q-signature=da80bd079b2c1fdb0dd961dea8568ee8d998****Connection: close
HTTP/1.1 200 OKContent-Type: application/xmlContent-Length: 219Connection: closeDate: Sat, 11 Apr 2020 17:51:35 GMTServer: tencent-cosx-cos-copy-source-version-id: MTg0NDUxNTc0NDYyMjQ2MzUzMjQx-cos-request-id: NWU5MjAzYTdfMWZjMDJhMDlfNTE4N18zNGU2****<?xml version="1.0" encoding="UTF-8"?><CopyObjectResult><ETag>"ee8de918d05640145b18f70f4c3aa602"</ETag><CRC64>16749565679157681890</CRC64><LastModified>2020-04-11T17:51:35Z</LastModified></CopyObjectResult>
PUT /exampleobject HTTP/1.1Host: destinationbucket-1250000000.cos.ap-beijing.myqcloud.comDate: Sat, 11 Apr 2020 17:51:56 GMTx-cos-copy-source: sourcebucket-1250000001.cos.ap-shanghai.myqcloud.com/example.jpgContent-Length: 0Authorization: q-sign-algorithm=sha1&q-ak=AKID8A0fBVtYFrNm02oY1g1JQQF0c3JO****&q-sign-time=1586627516;1586634716&q-key-time=1586627516;1586634716&q-header-list=content-length;date;host;x-cos-copy-source&q-url-param-list=&q-signature=2c79d63b6078ace6fc9430fb6533b9a9ade1****Connection: close
HTTP/1.1 200 OKContent-Type: application/xmlContent-Length: 272Connection: closeDate: Sat, 11 Apr 2020 17:51:56 GMTServer: tencent-cosx-cos-request-id: NWU5MjAzYmNfNjRiMDJhMDlfOTE3N18yYWI4****<?xml version="1.0" encoding="UTF-8"?><CopyObjectResult><ETag>"22e024392de860289f0baa7d6cf8a549"</ETag><CRC64>11596229263574363878</CRC64><LastModified>2020-04-11T17:51:56Z</LastModified><VersionId>MTg0NDUxNTc0NDYxOTI4MzU0MDI</VersionId></CopyObjectResult>
Was this page helpful?