Objects: copy

Copies a source object to a destination object. Optionally overrides metadata. Try it now.

The authenticated user must have READER permissions on the source object and WRITER permissions on the destination bucket. The copied object does not retain the ACLs of the original object. Instead, it gains any ACLs you specify in the copy method or, if you don't specify any ACLs, the default object ACLs of the bucket it is stored in.

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://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.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:
  • "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 owner, 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.

Try it!

Use the APIs Explorer below to call this method on live data and see the response.

Send feedback about...

Cloud Storage Documentation