Copies a source object to a destination object. Optionally overrides metadata. Try it now.
The authenticated user must have sufficient permission to use this method.
Use the copy
method to copy between objects in the same location and storage class.
When copying objects across locations or storage classes it's sometimes possible to use the
copy
method, but we recommend using the
rewrite
method instead
because if the source and destination are in different locations or storage classes the
copy
method calls the rewrite
method exactly once
behind the scenes. The larger the object the more likely that multiple rewrite
calls will be needed to complete the operation. If the single rewrite
call made by
copy
doesn't complete the operation it will result in a Deadline exceeded
error.
To copy an object encrypted by a customer-supplied encryption key, use the headers listed on the Encryption page in your request.
Request
HTTP request
POST https://storage.googleapis.com/storage/v1/b/sourceBucket/o/sourceObject/copyTo/b/destinationBucket/o/destinationObject
Parameters
Parameter name | Value | Description |
---|---|---|
Path parameters | ||
destinationBucket |
string |
Name of the bucket in which to store the new object. Overrides the provided object
metadata's bucket value, if any. For information about how to URL encode
object names to be path safe,
see Encoding URI path parts.
|
destinationObject |
string |
Name of the new object. Required when the object metadata is not otherwise provided. Overrides the object metadata's name value, if any.
|
sourceBucket |
string |
Name of the bucket in which to find the source object. |
sourceObject |
string |
Name of the source object. For information about how to URL encode object names to be path safe, see Encoding URI path parts. |
Optional query parameters | ||
destinationPredefinedAcl |
string |
Apply a predefined set of access controls to the destination object.
Acceptable values are:
iamConfiguration.uniformBucketLevelAccess.enabled is set to true , requests that include this parameter fail with a 400 Bad Request response.
|
ifGenerationMatch |
long |
Makes the operation conditional on whether the destination object's current generation matches the given value. Setting to 0 makes the operation succeed only if there are no live versions of the object. |
ifGenerationNotMatch |
long |
Makes the operation conditional on whether the destination object's current generation does not match the given value. If no live object exists, the precondition fails. Setting to 0 makes the operation succeed only if there is a live version of the object. |
ifMetagenerationMatch |
long |
Makes the operation conditional on whether the destination object's current metageneration matches the given value. |
ifMetagenerationNotMatch |
long |
Makes the operation conditional on whether the destination object's current metageneration does not match the given value. |
ifSourceGenerationMatch |
long |
Makes the operation conditional on whether the source object's generation matches the given value. |
ifSourceGenerationNotMatch |
long |
Makes the operation conditional on whether the source object's generation does not match the given value. |
ifSourceMetagenerationMatch |
long |
Makes the operation conditional on whether the source object's current metageneration matches the given value. |
ifSourceMetagenerationNotMatch |
long |
Makes the operation conditional on whether the source object's current metageneration does not match the given value. |
projection |
string |
Set of properties to return. Defaults to noAcl , unless the object resource specifies the acl property, when it defaults to full .
Acceptable values are:
|
sourceGeneration |
long |
If present, selects a specific revision of the source object (as opposed to the latest version, the default). |
userProject |
string |
The project to be billed for this request. Required for Requester Pays buckets. |
Request body
In the request body, optionally supply metadata to apply to the copied object using an object resource.
Response
If successful, this method returns an object resource in the response body.
Try it!
Use the APIs Explorer below to call this method on live data and see the response.