PHP Class Google\Cloud\Storage\StorageClient

Example: use Google\Cloud\ServiceBuilder; $cloud = new ServiceBuilder(); $storage = $cloud->storage(); StorageClient can be instantiated directly. use Google\Cloud\Storage\StorageClient; $storage = new StorageClient();
Inheritance: use trait Google\Cloud\ClientTrait
Datei anzeigen Open project: GoogleCloudPlatform/gcloud-php Class Usage Examples

Protected Properties

Property Type Description
$connection Google\Cloud\Storage\Connection\ConnectionInterface Represents a connection to Storage.

Public Methods

Method Description
__construct ( array $config = [] ) Create a Storage client.
bucket ( string $name ) : Bucket Lazily instantiates a bucket. There are no network requests made at this point. To see the operations that can be performed on a bucket please see {@see Google\Cloud\Storage\Bucket}.
buckets ( array $options = [] ) : Generator Fetches all buckets in the project.
createBucket ( string $name, array $options = [] ) : Bucket Create a bucket. Bucket names must be unique as Cloud Storage uses a flat namespace. For more information please see bucket name requirements

Method Details

__construct() public method

Create a Storage client.
public __construct ( array $config = [] )
$config array [optional] { Configuration options. @type string $projectId The project ID from the Google Developer's Console. @type CacheItemPoolInterface $authCache A cache used storing access tokens. **Defaults to** a simple in memory implementation. @type array $authCacheOptions Cache configuration options. @type callable $authHttpHandler A handler used to deliver Psr7 requests specifically for authentication. @type callable $httpHandler A handler used to deliver Psr7 requests. Only valid for requests sent over REST. @type string $keyFile The contents of the service account credentials .json file retrieved from the Google Developers Console. @type string $keyFilePath The full path to your service account credentials .json file retrieved from the Google Developers Console. @type int $retries Number of retries for a failed request. **Defaults to** `3`. @type array $scopes Scopes to be used for the request. }

bucket() public method

Example: $bucket = $storage->bucket('my-bucket');
public bucket ( string $name ) : Bucket
$name string The name of the bucket to request.
return Bucket

buckets() public method

Example: $buckets = $storage->buckets(); Get all buckets beginning with the prefix 'album'. $buckets = $storage->buckets([ 'prefix' => 'album' ]); foreach ($buckets as $bucket) { echo $bucket->name() . PHP_EOL; }
See also: https://cloud.google.com/storage/docs/json_api/v1/buckets/list Buckets list API documentation.
public buckets ( array $options = [] ) : Generator
$options array [optional] { Configuration options. @type integer $maxResults Maximum number of results to return per request. @type string $prefix Filter results with this prefix. @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. }
return Generator

createBucket() public method

Example: $bucket = $storage->createBucket('bucket'); Create a bucket with logging enabled. $bucket = $storage->createBucket('myBeautifulBucket', [ 'logging' => [ 'logBucket' => 'bucketToLogTo', 'logObjectPrefix' => 'myPrefix' ] ]);
See also: https://cloud.google.com/storage/docs/json_api/v1/buckets/insert Buckets insert API documentation.
public createBucket ( string $name, array $options = [] ) : Bucket
$name string Name of the bucket to be created.
$options array [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

Property Details

$connection protected_oe property

Represents a connection to Storage.
protected ConnectionInterface,Google\Cloud\Storage\Connection $connection
return Google\Cloud\Storage\Connection\ConnectionInterface