Concatenates a list of existing objects into a new object in the same bucket. Try it now or see an example .
The authenticated user must have
READER
permissions on every source
object
and
WRITER
permissions on the destination
bucket
.
Request
HTTP request
POST https://www.googleapis.com/storage/v1beta2/b/destinationBucket/o/destinationObject/compose
Parameters
Parameter name | Value | Description |
---|---|---|
Path parameters | ||
destinationBucket
|
string
|
Name of the bucket in which to store the new object. |
destinationObject
|
string
|
Name of the new object. |
Optional query parameters | ||
ifGenerationMatch
|
unsigned long
|
Makes the operation conditional on whether the object's current generation matches the given value. |
ifMetagenerationMatch
|
unsigned long
|
Makes the operation conditional on whether the object's current metageneration matches the given value. |
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 name | Value | Description | Notes |
---|---|---|---|
kind
|
string
|
The kind of item this is. | |
destination
|
nested object
|
Properties of the resulting object | writable |
sourceObjects[]
|
list
|
The list of source objects that will be concatenated into a single object. | |
sourceObjects[].
name
|
string
|
The source object's name. The source object's bucket is implicitly the destination bucket. | writable |
sourceObjects[].
generation
|
long
|
The generation of this object to use as the source. | writable |
sourceObjects[].
objectPreconditions
|
object
|
Conditions that must be met for this operation to execute. | |
sourceObjects[].objectPreconditions.
ifGenerationMatch
|
long
|
Only 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 |
Response
By default, this responds with an
object resource
in the response body. If you provide the URL parameter
alt=media
, then it will respond with the object data 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 .
composite_object_resource = {
'contentType': 'text/plain', # required
'contentLanguage': 'en',
'metadata': {'my-key': 'my-value'},
}
compose_req_body = {
'sourceObjects': [
{'name': source_object_name_1,
'objectPreconditions': {'ifGenerationMatch': source_generation_1}},
{'name': source_object_name_2,
'objectPreconditions': {'ifGenerationMatch': source_generation_2}}],
'destination': composite_object_resource
}
req = client.objects().compose(
destinationBucket=bucket_name,
destinationObject=composite_object_name,
body=compose_req_body)
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 .