Copies an object to a specified location. Optionally overrides metadata. Try it now or see an example .
The authenticated user must have
READER
permissions on the source
object
and
WRITER
permissions on the destination
bucket
.
Request
HTTP request
POST https://www.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.
|
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. |
Optional query parameters | ||
destinationPredefinedAcl
|
string
|
Apply a predefined set of access controls to the destination object.
Acceptable values are:
|
ifGenerationMatch
|
long
|
Makes the operation conditional on whether the destination object's current generation matches the given value. |
ifGenerationNotMatch
|
long
|
Makes the operation conditional on whether the destination object's current generation does not match the given value. |
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). |
Request body
In the request body, supply an object resource .
Response
If successful, this method returns an object resource in the response body.
Examples
Note: The code examples available for this method do not represent all supported programming languages (see the client libraries page for a list of supported languages).
Python
Uses the Python client library .
# The destination object resource is entirely optional. If empty, we use # the source object's metadata. if reuse_metadata: destination_object_resource = {} else: destination_object_resource = { 'contentLanguage': 'en', 'metadata': {'my-key': 'my-value'}, } req = client.objects().copy( sourceBucket=bucket_name, sourceObject=old_object, destinationBucket=bucket_name, destinationObject=new_object, body=destination_object_resource) resp = req.execute() print json.dumps(resp, indent=2)
Try it!
Use the APIs Explorer below to call this method on live data and see the response. Alternatively, try the standalone Explorer .