Menu
Storage.objects.rewrite
Rewrites a source object to a destination object. Optionally overrides metadata.
/b/{sourceBucket}/o/{sourceObject}/rewriteTo/b/{destinationBucket}/o/{destinationObject}Use it in a workflow
- Add a step and choose the Google Cloud Storage connector.
- Pick the Storage.objects.rewrite action (under objects).
- Fill in the fields below, then reference the result from later steps as
{{storageObjectsRewrite.response.data}}.
Request
Path parameters
sourceBucketstringrequiredName of the bucket in which to find the source object.
sourceObjectstringrequiredName of the source object. For information about how to URL encode object names to be path safe, see Encoding URI Path Parts.
destinationBucketstringrequiredName of the bucket in which to store the new object. Overrides the provided object metadata's bucket value, if any.
destinationObjectstringrequiredName of the new object. Required when the object metadata is not otherwise provided. Overrides the object metadata's name value, if any. For information about how to URL encode object names to be path safe, see Encoding URI Path Parts.
Query parameters
altstringData format for the response.
One ofjson
fieldsstringSelector specifying which fields to include in a partial response.
keystringAPI key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
oauth_tokenstringOAuth 2.0 token for the current user.
prettyPrintbooleanReturns response with indentations and line breaks.
quotaUserstringAn opaque string that represents a user for quota purposes. Must not exceed 40 characters.
uploadTypestringUpload protocol for media (e.g. "media", "multipart", "resumable").
userIpstringDeprecated. Please use quotaUser instead.
destinationKmsKeyNamestringResource name of the Cloud KMS key, of the form projects/my-project/locations/global/keyRings/my-kr/cryptoKeys/my-key, that will be used to encrypt the object. Overrides the object metadata's kms_key_name value, if any.
destinationPredefinedAclstringApply a predefined set of access controls to the destination object.
One ofauthenticatedReadbucketOwnerFullControlbucketOwnerReadprivateprojectPrivatepublicRead
ifGenerationMatchstringMakes the operation conditional on whether the 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.
ifGenerationNotMatchstringMakes the operation conditional on whether the 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.
ifMetagenerationMatchstringMakes the operation conditional on whether the destination object's current metageneration matches the given value.
ifMetagenerationNotMatchstringMakes the operation conditional on whether the destination object's current metageneration does not match the given value.
ifSourceGenerationMatchstringMakes the operation conditional on whether the source object's current generation matches the given value.
ifSourceGenerationNotMatchstringMakes the operation conditional on whether the source object's current generation does not match the given value.
ifSourceMetagenerationMatchstringMakes the operation conditional on whether the source object's current metageneration matches the given value.
ifSourceMetagenerationNotMatchstringMakes the operation conditional on whether the source object's current metageneration does not match the given value.
maxBytesRewrittenPerCallstringThe maximum number of bytes that will be rewritten per rewrite request. Most callers shouldn't need to specify this parameter - it is primarily in place to support testing. If specified the value must be an integral multiple of 1 MiB (1048576). Also, this only applies to requests where the source and destination span locations and/or storage classes. Finally, this value must not change across rewrite calls else you'll get an error that the rewriteToken is invalid.
projectionstringSet of properties to return. Defaults to noAcl, unless the object resource specifies the acl property, when it defaults to full.
One offullnoAcl
rewriteTokenstringInclude this field (from the previous rewrite response) on each rewrite request after the first one, until the rewrite response 'done' flag is true. Calls that provide a rewriteToken can omit all other request fields, but if included those fields must match the values provided in the first rewrite request.
sourceGenerationstringIf present, selects a specific revision of the source object (as opposed to the latest version, the default).
userProjectstringThe project to be billed for this request. Required for Requester Pays buckets.
Request body
Enter the body as JSON in the step's Body field.
aclarray<object>Access controls on the object.
bucketstringThe name of the bucket.
domainstringThe domain associated with the entity, if any.
emailstringThe email address associated with the entity, if any.
entitystringThe entity holding the permission, in one of the following forms: - user-userId - user-email - group-groupId - group-email - domain-domain - project-team-projectId - allUsers - allAuthenticatedUsers Examples: - The user liz@example.com would be user-liz@example.com. - The group example@googlegroups.com would be group-example@googlegroups.com. - To refer to all members of the Google Apps for Business domain example.com, the entity would be domain-example.com.
entityIdstringThe ID for the entity, if any.
etagstringHTTP 1.1 Entity tag for the access-control entry.
generationstring (int64)The content generation of the object, if applied to an object.
idstringThe ID of the access-control entry.
kindstringThe kind of item this is. For object access control entries, this is always storage#objectAccessControl.
Default "storage#objectAccessControl"
objectstringThe name of the object, if applied to an object.
projectTeamobject2 fieldsThe project team associated with the entity, if any.
rolestringThe access permission for the entity.
selfLinkstringThe link to this access-control entry.
bucketstringThe name of the bucket containing this object.
cacheControlstringCache-Control directive for the object data. If omitted, and the object is accessible to all anonymous users, the default will be public, max-age=3600.
componentCountinteger (int32)Number of underlying components that make up this object. Components are accumulated by compose operations.
contentDispositionstringContent-Disposition of the object data.
contentEncodingstringContent-Encoding of the object data.
contentLanguagestringContent-Language of the object data.
contentTypestringContent-Type of the object data. If an object is stored without a Content-Type, it is served as application/octet-stream.
crc32cstringCRC32c checksum, as described in RFC 4960, Appendix B; encoded using base64 in big-endian byte order. For more information about using the CRC32c checksum, see Hashes and ETags: Best Practices.
customTimestring (date-time)A timestamp in RFC 3339 format specified by the user for an object.
customerEncryptionobjectMetadata of customer-supplied encryption key, if the object is encrypted by such a key.
encryptionAlgorithmstringThe encryption algorithm.
keySha256stringSHA256 hash value of the encryption key.
etagstringHTTP 1.1 Entity tag for the object.
eventBasedHoldbooleanWhether an object is under event-based hold. Event-based hold is a way to retain objects until an event occurs, which is signified by the hold's release (i.e. this value is set to false). After being released (set to false), such objects will be subject to bucket-level retention (if any). One sample use case of this flag is for banks to hold loan documents for at least 3 years after loan is paid in full. Here, bucket-level retention is 3 years and the event is the loan being paid in full. In this example, these objects will be held intact for any number of years until the event has occurred (event-based hold on the object is released) and then 3 more years after that. That means retention duration of the objects begins from the moment event-based hold transitioned from true to false.
generationstring (int64)The content generation of this object. Used for object versioning.
idstringThe ID of the object, including the bucket name, object name, and generation number.
kindstringThe kind of item this is. For objects, this is always storage#object.
Default "storage#object"
kmsKeyNamestringNot currently supported. Specifying the parameter causes the request to fail with status code 400 - Bad Request.
md5HashstringMD5 hash of the data; encoded using base64. For more information about using the MD5 hash, see Hashes and ETags: Best Practices.
mediaLinkstringMedia download link.
metadataobjectUser-provided metadata, in key/value pairs.
metagenerationstring (int64)The version of the metadata for this object at this generation. Used for preconditions and for detecting changes in metadata. A metageneration number is only meaningful in the context of a particular generation of a particular object.
namestringThe name of the object. Required if not specified by URL parameter.
ownerobjectThe owner of the object. This will always be the uploader of the object.
entitystringThe entity, in the form user-userId.
entityIdstringThe ID for the entity.
retentionExpirationTimestring (date-time)A server-determined value that specifies the earliest time that the object's retention period expires. This value is in RFC 3339 format. Note 1: This field is not provided for objects with an active event-based hold, since retention expiration is unknown until the hold is removed. Note 2: This value can be provided even when temporary hold is set (so that the user can reason about policy without having to first unset the temporary hold).
selfLinkstringThe link to this object.
sizestring (uint64)Content-Length of the data in bytes.
storageClassstringStorage class of the object.
temporaryHoldbooleanWhether an object is under temporary hold. While this flag is set to true, the object is protected against deletion and overwrites. A common use case of this flag is regulatory investigations where objects need to be retained while the investigation is ongoing. Note that unlike event-based hold, temporary hold does not impact retention expiration time of an object.
timeCreatedstring (date-time)The creation time of the object in RFC 3339 format.
timeDeletedstring (date-time)The deletion time of the object in RFC 3339 format. Will be returned if and only if this version of the object has been deleted.
timeStorageClassUpdatedstring (date-time)The time at which the object's storage class was last changed. When the object is initially created, it will be set to timeCreated.
updatedstring (date-time)The modification time of the object metadata in RFC 3339 format. Set initially to object creation time and then updated whenever any metadata of the object changes. This includes changes made by a requester, such as modifying custom metadata, as well as changes made by Cloud Storage on behalf of a requester, such as changing the storage class based on an Object Lifecycle Configuration.
{
"acl": [
{
"bucket": "string",
"domain": "string",
"email": "string",
"entity": "string",
"entityId": "string",
"etag": "string",
"generation": "string",
"id": "string",
"kind": "storage#objectAccessControl",
"object": "string",
"projectTeam": {
"projectNumber": "string",
"team": "string"
},
"role": "string"
}
],
"bucket": "string",
"cacheControl": "string",
"componentCount": 0,
"contentDisposition": "string",
"contentEncoding": "string",
"contentLanguage": "string",
"contentType": "string",
"crc32c": "string",
"customTime": "2025-01-01T00:00:00Z",
"customerEncryption": {
"encryptionAlgorithm": "string",
"keySha256": "string"
},
"etag": "string"
}
Response
Returns 200 with an object. Read it in later steps with {{storageObjectsRewrite.response.data.<field>}}.
donebooleantrue if the copy is finished; otherwise, false if the copy is in progress. This property is always present in the response.
kindstringThe kind of item this is.
Default "storage#rewriteResponse"
objectSizestring (int64)The total size of the object being copied in bytes. This property is always present in the response.
resourceobjectAn object.
aclarray<object>13 fieldsAccess controls on the object.
bucketstringThe name of the bucket containing this object.
cacheControlstringCache-Control directive for the object data. If omitted, and the object is accessible to all anonymous users, the default will be public, max-age=3600.
componentCountinteger (int32)Number of underlying components that make up this object. Components are accumulated by compose operations.
contentDispositionstringContent-Disposition of the object data.
contentEncodingstringContent-Encoding of the object data.
contentLanguagestringContent-Language of the object data.
contentTypestringContent-Type of the object data. If an object is stored without a Content-Type, it is served as application/octet-stream.
crc32cstringCRC32c checksum, as described in RFC 4960, Appendix B; encoded using base64 in big-endian byte order. For more information about using the CRC32c checksum, see Hashes and ETags: Best Practices.
customTimestring (date-time)A timestamp in RFC 3339 format specified by the user for an object.
customerEncryptionobject2 fieldsMetadata of customer-supplied encryption key, if the object is encrypted by such a key.
etagstringHTTP 1.1 Entity tag for the object.
eventBasedHoldbooleanWhether an object is under event-based hold. Event-based hold is a way to retain objects until an event occurs, which is signified by the hold's release (i.e. this value is set to false). After being released (set to false), such objects will be subject to bucket-level retention (if any). One sample use case of this flag is for banks to hold loan documents for at least 3 years after loan is paid in full. Here, bucket-level retention is 3 years and the event is the loan being paid in full. In this example, these objects will be held intact for any number of years until the event has occurred (event-based hold on the object is released) and then 3 more years after that. That means retention duration of the objects begins from the moment event-based hold transitioned from true to false.
generationstring (int64)The content generation of this object. Used for object versioning.
idstringThe ID of the object, including the bucket name, object name, and generation number.
kindstringThe kind of item this is. For objects, this is always storage#object.
Default "storage#object"
kmsKeyNamestringNot currently supported. Specifying the parameter causes the request to fail with status code 400 - Bad Request.
md5HashstringMD5 hash of the data; encoded using base64. For more information about using the MD5 hash, see Hashes and ETags: Best Practices.
mediaLinkstringMedia download link.
metadataobjectUser-provided metadata, in key/value pairs.
metagenerationstring (int64)The version of the metadata for this object at this generation. Used for preconditions and for detecting changes in metadata. A metageneration number is only meaningful in the context of a particular generation of a particular object.
namestringThe name of the object. Required if not specified by URL parameter.
ownerobject2 fieldsThe owner of the object. This will always be the uploader of the object.
retentionExpirationTimestring (date-time)A server-determined value that specifies the earliest time that the object's retention period expires. This value is in RFC 3339 format. Note 1: This field is not provided for objects with an active event-based hold, since retention expiration is unknown until the hold is removed. Note 2: This value can be provided even when temporary hold is set (so that the user can reason about policy without having to first unset the temporary hold).
selfLinkstringThe link to this object.
sizestring (uint64)Content-Length of the data in bytes.
storageClassstringStorage class of the object.
temporaryHoldbooleanWhether an object is under temporary hold. While this flag is set to true, the object is protected against deletion and overwrites. A common use case of this flag is regulatory investigations where objects need to be retained while the investigation is ongoing. Note that unlike event-based hold, temporary hold does not impact retention expiration time of an object.
timeCreatedstring (date-time)The creation time of the object in RFC 3339 format.
timeDeletedstring (date-time)The deletion time of the object in RFC 3339 format. Will be returned if and only if this version of the object has been deleted.
timeStorageClassUpdatedstring (date-time)The time at which the object's storage class was last changed. When the object is initially created, it will be set to timeCreated.
updatedstring (date-time)The modification time of the object metadata in RFC 3339 format. Set initially to object creation time and then updated whenever any metadata of the object changes. This includes changes made by a requester, such as modifying custom metadata, as well as changes made by Cloud Storage on behalf of a requester, such as changing the storage class based on an Object Lifecycle Configuration.
rewriteTokenstringA token to use in subsequent requests to continue copying data. This token is present in the response only when there is more data to copy.
totalBytesRewrittenstring (int64)The total bytes written so far, which can be used to provide a waiting user with a progress indicator. This property is always present in the response.
{
"done": false,
"kind": "storage#rewriteResponse",
"objectSize": "string",
"resource": {
"acl": [
{
"bucket": "string",
"domain": "string",
"email": "string",
"entity": "string",
"entityId": "string",
"etag": "string",
"generation": "string",
"id": "string",
"kind": "storage#objectAccessControl",
"object": "string",
"projectTeam": {
"projectNumber": "string",
"team": "string"
},
"role": "string"
}
],
"bucket": "string",
"cacheControl": "string",
"componentCount": 0,
"contentDisposition": "string",
"contentEncoding": "string",
"contentLanguage": "string",
"contentType": "string",
"crc32c": "string",
"customTime": "2025-01-01T00:00:00Z",
"customerEncryption": {
"encryptionAlgorithm": "string",
"keySha256": "string"
},
"etag": "string"
},
"rewriteToken": "string",
"totalBytesRewritten": "string"
}
Need more? See the Google Cloud Storage guide for connection setup and behaviour shared by every action.