/** * Create a bucket. Bucket names must be unique as Cloud Storage uses a flat * namespace. For more information please see * [bucket name requirements](https://cloud.google.com/storage/docs/naming#requirements) * * Example: * ``` * $bucket = $storage->createBucket('bucket'); * ``` * * ``` * // Create a bucket with logging enabled. * $bucket = $storage->createBucket('myBeautifulBucket', [ * 'logging' => [ * 'logBucket' => 'bucketToLogTo', * 'logObjectPrefix' => 'myPrefix' * ] * ]); * ``` * * @see https://cloud.google.com/storage/docs/json_api/v1/buckets/insert Buckets insert API documentation. * * @param string $name Name of the bucket to be created. * @param array $options [optional] { * Configuration options. * * @type string $predefinedAcl Apply a predefined set of access controls * to this bucket. * @type string $predefinedDefaultObjectAcl Apply a predefined set of * default object access controls to this bucket. * @type string $projection Determines which properties to return. May * be either 'full' or 'noAcl'. * @type string $fields Selector which will cause the response to only * return the specified fields. * @type array $acl Access controls on the bucket. * @type array $cors The bucket's Cross-Origin Resource Sharing (CORS) * configuration. * @type array $defaultObjectAcl Default access controls to apply to new * objects when no ACL is provided. * @type array $lifecycle The bucket's lifecycle configuration. * @type string $location The location of the bucket. **Defaults to** * `"US"`. * @type array $logging The bucket's logging configuration, which * defines the destination bucket and optional name prefix for the * current bucket's logs. * @type string $storageClass The bucket's storage class. This defines * how objects in the bucket are stored and determines the SLA and * the cost of storage. Values include MULTI_REGIONAL, REGIONAL, * NEARLINE, COLDLINE, STANDARD and DURABLE_REDUCED_AVAILABILITY. * @type array $versioning The bucket's versioning configuration. * @type array $website The bucket's website configuration. * } * @return Bucket */ public function createBucket($name, array $options = []) { $response = $this->connection->insertBucket($options + ['name' => $name, 'project' => $this->projectId]); return new Bucket($this->connection, $name, $response); }
public function testGetsIdentity() { $object = new StorageObject($this->connection->reveal(), $name = 'object.txt', $bucketName = 'bucket'); $this->assertEquals($name, $object->identity()['object']); $this->assertEquals($bucketName, $object->identity()['bucket']); }