To copy an object, you make a
PUT request that is scoped to the new bucket and
object name and you specify the source object with the
request header. To copy an object to itself you must use the
x-goog-metadata-directive header with a value of
REPLACE and you must
specify any object metadata for the copied object in your request.
If the source and destination buckets have different locations, the copy request incurs network usage charges.
If any of the conditional copy headers fail to match the condition you specify
you will get a 412 Precondition
Failed status code and the body of the error response will have
PreconditionFailed in the
Query string parameters
This request does not typically include query string parameters.
In addition to common request headers, the following can be used.
||The compression algorithm that was used to compress the object you are uploading.||No|
||A header you can set on an object that specifies presentational information about how the object data is to be transmitted.||No|
||The predefined ACL that you want to apply to the object. Do not use if you are using the
||A user-specified date and time.||No|
||The instructions for handling metadata during a copy operation. Can be
||An extension header that can be used to store additional metadata that is not provided by the other fields.||No|
||The bucket/object path to the object you want to copy. For example, /travel-maps/paris.jpg.||Yes|
||The generation number of the object you want to copy.||No|
||An ETag. If the ETag you specify matches the ETag of the source object, then the source object is copied.||No|
||An ETag. If the ETag you specify does not match the Etag of the source object, then the object is copied.||No|
||A date and time. If the date and time you specify is earlier than the
||A date and time. If the date and time you specify is later than the
||The customer-managed encryption key to use to encrypt the copied object.||No|
Request body elements
This request does not include an XML document in the request body.
The following syntax applies to PUT Object requests that use the
copy-source request header and the related conditional copy request
PUT /OBJECT_NAME HTTP/1.1 Host: BUCKET_NAME.storage.googleapis.com Date: DATE Content-Length: REQUEST_BODY_LENGTH Content-Type: MIME_TYPE Authorization: AUTHENTICATION_STRING x-goog-copy-source: /BUCKET_NAME/OBJECT_NAME x-goog-copy-source-if-match: ETAG x-goog-copy-source-if-none-match: ETAG x-goog-copy-source-if-unmodified-since: DATE x-goog-copy-source-if-modified-since: DATE x-goog-metadata-directive: COPY | REPLACE
The request can return a variety of response headers depending on the request headers you use.
Response body elements
The following response elements are returned when you use the
source request header or any of the related conditional copy request
|CopyObjectResult||Container for copy information.|
|ETag||The ETag of the newly-copied object.|
|LastModified||The date and time that the source object was last modified prior to the current copy operation.|
The following sample uses the
x-goog-copy-source request header to
copy an object named paris.jpg from a bucket named travel-maps to a bucket
PUT /paris.jpg HTTP/1.1 Host: city-maps.storage.googleapis.com Date: Fri, 23 Jul 2010 21:27:36 GMT Content-Length: 0 x-goog-copy-source: travel-maps/paris.jpg Authorization: Bearer ya29.AHES6ZRVmB7fkLtd1XTmq6mo0S1wqZZi3-Lh_s-6Uw7p8vtgSwg
HTTP/1.1 200 OK ETag: "9930c6204b2f14e1a4496569dc200186" Date: Fri, 23 Jul 2010 21:27:37 GMT Expires: Mon, 01 Jan 1990 00:00:00 GMT Cache-Control: no-cache, no-store, must-revalidate Content-Length: 175 Content-Type: text/html <?xml version='1.0' encoding='UTF-8'?> <CopyObjectResult> <LastModified>2010-06-17T16:18:08.291Z</LastModified> <ETag>"9930c6204b2f14e1a4496569dc200186"</ETag> </CopyObjectResult>