Objects: compose

Concatenates a list of existing objects into a new object in the same bucket. The existing source objects are unaffected by this operation.

See Composite objects for a general discussion of object composition, and see Compose objects for tool-specific guides to performing a composition.

Required permissions

The authenticated user must have the storage.objects.create and storage.objects.get IAM permissions to use this method. If the new composite object overwrites an existing object, the authenticated user must also have the storage.objects.delete permission. If the request body includes the retention property, the authenticated user must also have the storage.objects.setRetention IAM permission.

Request

HTTP request

POST https://storage.googleapis.com/storage/v1/b/bucket/o/destinationObject/compose

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

Parameter nameValueDescription
Path parameters
bucketstringName of the bucket containing the source objects. The destination object is stored in this bucket.
destinationObjectstringName of the new object. For information about how to URL encode object names to be path safe, see Encoding URI path parts.
Optional query parameters
destinationPredefinedAclstringApply 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.
If iamConfiguration.uniformBucketLevelAccess.enabled is set to true, requests that include this parameter fail with a 400 Bad Request response.
ifGenerationMatchlongMakes the operation conditional on there being a live destination object with a generation number that matches the given value. Setting ifGenerationMatch to 0 makes the operation succeed only if there is no live destination object.
ifMetagenerationMatchlongMakes the operation conditional on there being a live destination object with a metageneration number that matches the given value.
kmsKeyNamestringResource name of the Cloud KMS key that will be used to encrypt the composed object. If not specified, the request uses the bucket's default Cloud KMS key, if any, or else it uses standard Cloud Storage encryption.
Optional extension headers
X-Goog-Encryption-AlgorithmstringThe encryption algorithm to use, which must be AES256. Used when encrypting the composed object with a customer-supplied encryption key.
X-Goog-Encryption-KeystringAn RFC 4648 Base64-encoded string of your AES-256 encryption key. Used when encrypting the composed object with a customer-supplied encryption key.
X-Goog-Encryption-Key-Sha256stringAn RFC 4648 Base64-encoded string of the SHA256 hash of your encryption key. Used when encrypting the composed object with a customer-supplied encryption key.

Request body

In the request body, supply data with the following structure:

{
  "kind": "storage#composeRequest",
  "sourceObjects": [
    {
      "name": string,
      "generation": "long",
      "objectPreconditions": {
        "ifGenerationMatch": "long"
      }
    }
  ],
  "destination": objects Resource
}
Property nameValueDescriptionNotes
kindstringThe kind of item this is.
destinationnested objectProperties of the resulting object.writable
sourceObjects[]listThe list of source objects that will be concatenated into a single object. There is a limit of 32 components that can be composed in a single operation.
sourceObjects[].namestringThe source object's name. All source objects must reside in the same bucket and use the same storage class.writable
sourceObjects[].generationlong1The generation of this object to use as the source.writable
sourceObjects[].objectPreconditionsobjectConditions that must be met for this operation to execute.
sourceObjects[].objectPreconditions.ifGenerationMatchlong1Only perform the composition if the generation of the source object that would be used matches this value. If this value and a generation are both specified, they must be the same value or the call will fail.writable
1 This property is a string formatted as the specified value type.

Response

If successful, this method returns an object resource in the response body, with the owner and acl properties omitted.

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.