compose() public method

Please note that all objects to be composed must come from the same bucket. Example: $sourceObjects = ['log1.txt', 'log2.txt']; $singleObject = $bucket->compose($sourceObjects, 'combined-logs.txt'); Use an instance of StorageObject. $sourceObjects = [ $bucket->object('log1.txt'), $bucket->object('log2.txt') ]; $singleObject = $bucket->compose($sourceObjects, 'combined-logs.txt');
See also: https://cloud.google.com/storage/docs/json_api/v1/objects/compose Objects compose API documentation
public compose ( array $sourceObjects, string $name, array $options = [] ) : StorageObject
$sourceObjects array The objects to compose.
$name string The name of the composed object.
$options array [optional] { Configuration options. @type string $predefinedAcl Predefined ACL to apply to the composed object. Acceptable values include, `"authenticatedRead"`, `"bucketOwnerFullControl"`, `"bucketOwnerRead"`, `"private"`, `"projectPrivate"`, and `"publicRead"`. **Defaults to** `"private"`. @type array $metadata Metadata to apply to the composed object. The available options for metadata are outlined at the [JSON API docs](https://cloud.google.com/storage/docs/json_api/v1/objects/insert#request-body). @type string $ifGenerationMatch Makes the operation conditional on whether the object's current generation matches the given value. @type string $ifMetagenerationMatch Makes the operation conditional on whether the object's current metageneration matches the given value. }
return StorageObject
Ejemplo n.º 1
0
 /**
  * @dataProvider composeProvider
  */
 public function testComposesObjects($metadata, $objects, $expectedSourceObjects)
 {
     $acl = 'private';
     $destinationBucket = 'bucket';
     $destinationObject = 'combined-files.txt';
     $this->connection->composeObject(['destinationPredefinedAcl' => $acl, 'destination' => $metadata + ['contentType' => 'text/plain'], 'sourceObjects' => $expectedSourceObjects, 'destinationBucket' => $destinationBucket, 'destinationObject' => $destinationObject])->willReturn(['name' => $destinationObject, 'generation' => 1])->shouldBeCalledTimes(1);
     $bucket = new Bucket($this->connection->reveal(), $destinationBucket);
     $object = $bucket->compose($objects, $destinationObject, ['predefinedAcl' => $acl, 'metadata' => $metadata]);
     $this->assertEquals($destinationObject, $object->name());
 }