Copies a source object to a destination object. Optionally overrides metadata.
Generally, you should use the rewrite
method instead of the copy
method: the copy
method uses the rewrite
method, but calls it exactly once. Larger objects can require multiple rewrite
calls, so copy attempts of such objects can lead to Payload too large
errors.
Request
HTTP request
POST https://storage.googleapis.com/storage/v1/b/ sourceBucket /o/ sourceObject /copyTo/b/ destinationBucket /o/ destinationObject
In addition to standard query parameters , the following query parameters apply to this method.
To see an example of how to include query parameters in a request, see the JSON API Overview page.
Parameters
destinationBucket
string
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
value, if any.sourceBucket
string
sourceObject
string
destinationKmsKeyName
string
If the parameter is not specified, the request uses the destination bucket's default encryption key, if any, or else it uses standard Cloud Storage encryption .
If the object is large, re-encryption with the key may take too long and result in a
Deadline exceeded
error. For large objects, consider using the rewrite
method instead.destinationPredefinedAcl
string
Acceptable values are:
-
authenticatedRead: Object owner getsOWNERaccess, andallAuthenticatedUsersgetREADERaccess. -
bucketOwnerFullControl: Object owner getsOWNERaccess, and project team owners getOWNERaccess. -
bucketOwnerRead: Object owner getsOWNERaccess, and project team owners getREADERaccess. -
private: Object owner getsOWNERaccess. -
projectPrivate: Object owner getsOWNERaccess, and project team members get access according to their roles. -
publicRead: Object owner getsOWNERaccess, andallUsersgetREADERaccess.
iamConfiguration.uniformBucketLevelAccess.enabled
is set to true
, requests that include this parameter fail with a 400 Bad Request
response.ifGenerationMatch
long
ifGenerationMatch
to 0 makes the
operation succeed only if there is no live destination object.ifGenerationNotMatch
long
ifGenerationNotMatch
to 0 makes the operation
succeed if there is a live version of the object.ifMetagenerationMatch
long
ifMetagenerationNotMatch
long
ifSourceGenerationMatch
long
ifSourceGenerationNotMatch
long
ifSourceMetagenerationMatch
long
ifSourceMetagenerationNotMatch
long
projection
string
noAcl
, unless the object resource
specifies the acl
property, when it defaults to full
.Acceptable values are:
-
full: Include all properties. -
noAcl: Omit theowner,aclproperty.
sourceGeneration
long
X-Goog-Copy-Source-Encryption-Algorithm
string
AES256
. Used if the source
object was encrypted with a customer-supplied
encryption key
.X-Goog-Copy-Source-Encryption-Key
string
X-Goog-Copy-Source-Encryption-Key-Sha256
string
X-Goog-Encryption-Algorithm
string
AES256
. Used for encrypting
the destination object with a customer-supplied encryption
key
.X-Goog-Encryption-Key
string
X-Goog-Encryption-Key-Sha256
string
Request body
In the request body, supply metadata to apply to the destination object by using an object resource
. If the request body
is empty, editable metadata
from the source object
is applied to the destination object, with the exception of any ACLs, object holds, or retention
configuration set on the source object. If you want to retain these from
the original object, they must be included in the request body.
Response
If successful, this method returns an object resource in the response body.
For information about status and error codes returned by this API, see the reference page .
Try it!
Use the APIs Explorer below to call this method on live data and see the response.

