Please note that the contents of this offline web site may be out of date. To access the most recent documentation visit the online version .
Note that links that point to online resources are green in color and will open in a new window.
We would love it if you could give us feedback about this material by filling this form (You have to be online to fill it)



Objects: copy

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:
  • " authenticatedRead ": Object owner gets OWNER access, and allAuthenticatedUsers get READER access.
  • " bucketOwnerFullControl ": Object owner gets OWNER access, and project team owners get OWNER access.
  • " bucketOwnerRead ": Object owner gets OWNER access, and project team owners get READER access.
  • " private ": Object owner gets OWNER access.
  • " projectPrivate ": Object owner gets OWNER access, and project team members get access according to their roles.
  • " publicRead ": Object owner gets OWNER access, and allUsers get READER access.
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:
  • " full ": Include all properties.
  • " noAcl ": Omit the acl property.
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 .

Authentication required

You need to be signed in with Google+ to do that.

Signing you in...

Google Developers needs your permission to do that.