CopyObject

최신 업데이트:2022-03-01 18:01:05

This API is used to create a copy of an object that already exists on Object Storage.

  1. You can see a copy opereation as a GET operation along with a PUT operation. By adding x-wos-copy-source to request header, you can move copy of the object to destination bucket by put method.
  2. If you want to copy the object with restrictions, for example, it can be copied only when etag matches or the object has been modified before or after a certain time, please put request headers as x-wos-copy-source-if-match, x-wos-copy- source-if-none-match, x-wos-copy-source-if-unmodified-since, x-wos-copy-source-if-modified-since.
  3. Metadata of the object will be copied as well when performing an object copy operation. You can put metadata you want in the copy request to replace the orgin one.

Request syntax

PUT /destinationObjectName HTTP/1.1
Host: Bucket.Endpoint
x-wos-copy-source: /sourceBucket/sourceObject
x-wos-copy-source-if-match: etag
x-wos-copy-source-if-none-match: etag
x-wos-copy-source-if-unmodified-since: time_stamp
x-wos-meta-*:metainfo
Authorization: Authorization string
Date: date

URI request parameters

None.

Request header

Except the Common Request Headers , you can also use the following headers:

Header Description Required
x-wos-copy-source Specify the source bucket and source object name. This header must be URL encoded.
Type: String
Example: x-wos-copy-source:/src_bucket/src_object
Yes
x-wos-copy-source-if-match TOnly when value of x-wos-copy-source-if-none-match matches etag of the source object will the object copy operation be performed, otherwise 412 ( precondition failed ) will be returned.
Type: String.
Example: x-wos-copy-source-if-none-match: etag
Constraint: This parameter can not be used together with other parameters, except x-wos-copy-source-if-unmodified/modified-since.
No
x-wos-copy-source-if-none-match Only when value of x-wos-copy-source-if-none-match does not match etag of the source object will the object copy operation be performed, otherwise 412 ( precondition failed ) will be returned.
Type: String.
Example: x-wos-copy-source-if-none-match: etag
No
x-wos-copy-source-if-unmodified-since Only when the source object has not been modified after the time specified by this parameter, will the copy object operation be performed, otherwise 412 ( precondition failed ) will be returned. This parameter can not be used together with other parameters, except x-wos-copy-source-if-match.
Type: HTTP time string in the format of http://www.ietf.org/rfc/rfc2616.txt .
Example: x-wos-copy-source-if-unmodified -since: timestamp
No
x-wos-copy-source-if-modified-since Only when the source object has been modified during the time specified by this parameter, will the copy object operation be performed, otherwise 412 ( precondition failed ) will be returned. This parameter can not be used together with other parameters, except x-wos-copy-source-if-none-match.
Type: HTTP time string in the format of http://www.ietf.org/rfc/rfc2616.txt .
Example: x-wos-copy-source-if-modified-since: time-stamp
No
x-wos-metadata-directive Replace metadata of the copy with that in x-wos-meta-*(REPLACE) or not(COPY).
Type: String.
Example: x-wos-metadata-directive : COPY
No
x-wos-meta-* Customized metadata, which will be be returned in header of headObject and getObjectType.
Type: String.
Example: x-wos-metadata-abc : test
No

Request body

None.

Response syntax

HTTP/1.1 status_code
x-wos-request-id: request id
Content-Type: type
Date: date
Content-Length: length
Server: WS-web-server

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<CopyObjectResult xmlns=" http://wcs.chinanetcenter.com/document">
    <LastModified>modifiedDate</LastModified>
    <ETag>etagValue</ETag>
</CopyObjectResult>

Response header

Please use Common Response Headers .

Response body

Name Description
CopyObjectResult Container of the copy.
Type : XML
LastModified Last modified time.
Type: String
ETag ETag value.
Type : String

Special errors

Http Status Error Code Message
400 Bad Request InvalidArgument Copy Source must mention the source bucket and key: sourcebucket/sourcekey
400 Bad Request EntityTooLarge Your proposed copy exceeds the maximum allowed object size.
400 Bad Request InvalidRequest This copy request is illegal because it is trying to copy an object to itself without changing the object’s metadata attribute.

Example

PUT /destobject HTTP/1.1
Host: bucket.s3-cn-east-1.wcsapi.com
Date: Sat, 03 Dec 2011 08:48:07 +0000
Authorization: WOS BF6C09F302931425E9A7:2rZR+iaH8xUewvUKuicLhLHpNoU=
x-wos-copy-source: /srcbucket/srcobject

HTTP/1.1 200 OK
x-wos-request-id: 318BC8BC148832E5
Date: Wed, 28 Oct 2009 22:32:00 GMT
Connection: close
Server: WS-Web-Server
<CopyObjectResult>
  <LastModified>2009-10-28T22:32:00</LastModified>
  <ETag>"9b2cf535f27731c974343645a3985328"</ETag>
</CopyObjectResult>
이 문서의 내용이 도움이 되었습니까?
아니오
정상적으로 제출되었습니다.피드백을 주셔서 감사합니다.앞으로도 개선을 위해 노력하겠습니다.