Cloud Storage Client - Class StorageObject (1.32.0)

Reference documentation and code samples for the Cloud Storage Client class StorageObject.

Objects are the individual pieces of data that you store in Google Cloud Storage.

Example:

use Google\Cloud\Storage\StorageClient;

$storage = new StorageClient();

$bucket = $storage->bucket('my-bucket');
$object = $bucket->object('my-object');

Namespace

Google \ Cloud \ Storage

Methods

__construct

Parameters
NameDescription
connection Google\Cloud\Storage\Connection\ConnectionInterface

Represents a connection to Cloud Storage.

name string

The object's name.

bucket string

The name of the bucket the object is contained in.

generation string

[optional] The generation of the object.

info array

[optional] The object's metadata.

encryptionKey string

[optional] An AES-256 customer-supplied encryption key.

encryptionKeySHA256 string

[optional] The SHA256 hash of the customer-supplied encryption key.

acl

Configure ACL for this object.

Example:

$acl = $object->acl();
Returns
TypeDescription
Google\Cloud\Storage\Acl

exists

Check whether or not the object exists.

Example:

if ($object->exists()) {
    echo 'Object exists!';
}
Parameter
NameDescription
options array

[optional] Configuration options.

Returns
TypeDescription
bool

delete

Delete the object.

Example:

$object->delete();
Parameters
NameDescription
options array

Configuration options.

↳ ifGenerationMatch string

Makes the operation conditional on whether the object's current generation matches the given value.

↳ ifGenerationNotMatch string

Makes the operation conditional on whether the object's current generation does not match the given value.

↳ ifMetagenerationMatch string

Makes the operation conditional on whether the object's current metageneration matches the given value.

↳ ifMetagenerationNotMatch string

Makes the operation conditional on whether the object's current metageneration does not match the given value.

Returns
TypeDescription
void

update

Update the object. Upon receiving a result the local object's data will be updated.

Example:

// Add custom metadata to an existing object.
$object->update([
    'metadata' => [
        'albumType' => 'family'
    ]
]);
Parameters
NameDescription
metadata array

The available options for metadata are outlined at the JSON API docs

options array

Configuration options.

↳ ifGenerationMatch string

Makes the operation conditional on whether the object's current generation matches the given value.

↳ ifGenerationNotMatch string

Makes the operation conditional on whether the object's current generation does not match the given value.

↳ ifMetagenerationMatch string

Makes the operation conditional on whether the object's current metageneration matches the given value.

↳ ifMetagenerationNotMatch string

Makes the operation conditional on whether the object's current metageneration does not match the given value.

↳ predefinedAcl string

Predefined ACL to apply to the object. Acceptable values include, "authenticatedRead", "bucketOwnerFullControl", "bucketOwnerRead", "private", "projectPrivate", and "publicRead".

↳ projection string

Determines which properties to return. May be either 'full' or 'noAcl'.

↳ fields string

Selector which will cause the response to only return the specified fields.

Returns
TypeDescription
array

copy

Copy the object to a destination bucket.

Please note that if the destination bucket is the same as the source bucket and a new name is not provided the source object will be replaced with the copy of itself.

Example:

// Provide your destination bucket as a string and retain the source
// object's name.
$copiedObject = $object->copy('otherBucket');
// Provide your destination bucket as a bucket object and choose a new
// name for the copied object.
$otherBucket = $storage->bucket('otherBucket');
$copiedObject = $object->copy($otherBucket, [
    'name' => 'newFile.txt'
]);
Parameters
NameDescription
destination Google\Cloud\Storage\Bucket|string

The destination bucket.

options array

Configuration options.

↳ name string

The name of the destination object. Defaults to the name of the source object.

↳ predefinedAcl string

Predefined ACL to apply to the object. Acceptable values include, "authenticatedRead", "bucketOwnerFullControl", "bucketOwnerRead", "private", "projectPrivate", and "publicRead".

↳ encryptionKey string

A base64 encoded AES-256 customer-supplied encryption key. It will be neccesary to provide this when a key was used during the object's creation.

↳ encryptionKeySHA256 string

Base64 encoded SHA256 hash of the customer-supplied encryption key. This value will be calculated from the encryptionKey on your behalf if not provided, but for best performance it is recommended to pass in a cached version of the already calculated SHA.

↳ ifGenerationMatch string

Makes the operation conditional on whether the destination object's current generation matches the given value.

↳ ifGenerationNotMatch string

Makes the operation conditional on whether the destination object's current generation does not match the given value.

↳ ifMetagenerationMatch string

Makes the operation conditional on whether the destination object's current metageneration matches the given value.

↳ ifMetagenerationNotMatch string

Makes the operation conditional on whether the destination object's current metageneration does not match the given value.

↳ ifSourceGenerationMatch string

Makes the operation conditional on whether the source object's current generation matches the given value.

↳ ifSourceGenerationNotMatch string

Makes the operation conditional on whether the source object's current generation does not match the given value.

↳ ifSourceMetagenerationMatch string

Makes the operation conditional on whether the source object's current metageneration matches the given value.

↳ ifSourceMetagenerationNotMatch string

Makes the operation conditional on whether the source object's current metageneration does not match the given value.

Returns
TypeDescription
Google\Cloud\Storage\StorageObject

rewrite

Rewrite the object to a destination bucket.

This method copies data using multiple requests so large objects can be copied with a normal length timeout per request rather than one very long timeout for a single request.

Please note that if the destination bucket is the same as the source bucket and a new name is not provided the source object will be replaced with the copy of itself.

Example:

// Provide your destination bucket as a string and retain the source
// object's name.
$rewrittenObject = $object->rewrite('otherBucket');
// Provide your destination bucket as a bucket object and choose a new
// name for the copied object.
$otherBucket = $storage->bucket('otherBucket');
$rewrittenObject = $object->rewrite($otherBucket, [
    'name' => 'newFile.txt'
]);
// Rotate customer-supplied encryption keys.
$key = file_get_contents(__DIR__ . '/key.txt');
$destinationKey = base64_encode(openssl_random_pseudo_bytes(32)); // Make sure to remember your key.

$rewrittenObject = $object->rewrite('otherBucket', [
    'encryptionKey' => $key,
    'destinationEncryptionKey' => $destinationKey
]);
Parameters
NameDescription
destination Google\Cloud\Storage\Bucket|string

The destination bucket.

options array

Configuration options.

↳ name string

The name of the destination object. Defaults to the name of the source object.

↳ predefinedAcl string

Predefined ACL to apply to the object. Acceptable values include, "authenticatedRead", "bucketOwnerFullControl", "bucketOwnerRead", "private", "projectPrivate", and "publicRead".

↳ maxBytesRewrittenPerCall string

The maximum number of bytes that will be rewritten per rewrite request. Most callers shouldn't need to specify this parameter - it is primarily in place to support testing. If specified the value must be an integral multiple of 1 MiB (1048576). Also, this only applies to requests where the source and destination span locations and/or storage classes.

↳ encryptionKey string

A base64 encoded AES-256 customer-supplied encryption key. It will be neccesary to provide this when a key was used during the object's creation.

↳ encryptionKeySHA256 string

Base64 encoded SHA256 hash of the customer-supplied encryption key. This value will be calculated from the encryptionKey on your behalf if not provided, but for best performance it is recommended to pass in a cached version of the already calculated SHA.

↳ destinationEncryptionKey string

A base64 encoded AES-256 customer-supplied encryption key that will be used to encrypt the rewritten object.

↳ destinationEncryptionKeySHA256 string

Base64 encoded SHA256 hash of the customer-supplied destination encryption key. This value will be calculated from the destinationEncryptionKey on your behalf if not provided, but for best performance it is recommended to pass in a cached version of the already calculated SHA.

↳ destinationKmsKeyName string

Name of the Cloud KMS key that will be used to encrypt the object. Should be in the format projects/my-project/locations/kr-location/keyRings/my-kr/cryptoKeys/my-key. Please note the KMS key ring must use the same location as the destination bucket.

↳ ifGenerationMatch string

Makes the operation conditional on whether the destination object's current generation matches the given value.

↳ ifGenerationNotMatch string

Makes the operation conditional on whether the destination object's current generation does not match the given value.

↳ ifMetagenerationMatch string

Makes the operation conditional on whether the destination object's current metageneration matches the given value.

↳ ifMetagenerationNotMatch string

Makes the operation conditional on whether the destination object's current metageneration does not match the given value.

↳ ifSourceGenerationMatch string

Makes the operation conditional on whether the source object's current generation matches the given value.

↳ ifSourceGenerationNotMatch string

Makes the operation conditional on whether the source object's current generation does not match the given value.

↳ ifSourceMetagenerationMatch string

Makes the operation conditional on whether the source object's current metageneration matches the given value.

↳ ifSourceMetagenerationNotMatch string

Makes the operation conditional on whether the source object's current metageneration does not match the given value.

Returns
TypeDescription
Google\Cloud\Storage\StorageObject

rename

Renames the object.

Please note that there is no atomic rename provided by the Storage API. This method is for convenience and is a set of sequential calls to copy and delete. Upon success the source object's metadata will be cleared, please use the returned object instead.

Example:

$object2 = $object->rename('object2.txt');
echo $object2->name();
Parameters
NameDescription
name string

The new name.

options array

Configuration options.

↳ predefinedAcl string

Predefined ACL to apply to the object. Acceptable values include, "authenticatedRead", "bucketOwnerFullControl", "bucketOwnerRead", "private", "projectPrivate", and "publicRead".

↳ encryptionKey string

A base64 encoded AES-256 customer-supplied encryption key. It will be neccesary to provide this when a key was used during the object's creation.

↳ encryptionKeySHA256 string

Base64 encoded SHA256 hash of the customer-supplied encryption key. This value will be calculated from the encryptionKey on your behalf if not provided, but for best performance it is recommended to pass in a cached version of the already calculated SHA.

↳ ifGenerationMatch string

Makes the operation conditional on whether the destination object's current generation matches the given value.

↳ ifGenerationNotMatch string

Makes the operation conditional on whether the destination object's current generation does not match the given value.

↳ ifMetagenerationMatch string

Makes the operation conditional on whether the destination object's current metageneration matches the given value.

↳ ifMetagenerationNotMatch string

Makes the operation conditional on whether the destination object's current metageneration does not match the given value.

↳ ifSourceGenerationMatch string

Makes the operation conditional on whether the source object's current generation matches the given value.

↳ ifSourceGenerationNotMatch string

Makes the operation conditional on whether the source object's current generation does not match the given value.

↳ ifSourceMetagenerationMatch string

Makes the operation conditional on whether the source object's current metageneration matches the given value.

↳ ifSourceMetagenerationNotMatch string

Makes the operation conditional on whether the source object's current metageneration does not match the given value.

↳ destinationBucket string

Will move to this bucket if set. If not set, will default to the same bucket.

Returns
TypeDescription
Google\Cloud\Storage\StorageObjectThe renamed object.

downloadAsString

Download an object as a string.

For an example of setting the range header to download a subrange of the object please see Google\Cloud\Storage\Google\Cloud\Storage\StorageObject::downloadAsStream().

Example:

$string = $object->downloadAsString();
echo $string;
Parameters
NameDescription
options array

Configuration Options.

↳ encryptionKey string

An AES-256 customer-supplied encryption key. It will be neccesary to provide this when a key was used during the object's creation. If provided one must also include an encryptionKeySHA256.

↳ encryptionKeySHA256 string

The SHA256 hash of the customer-supplied encryption key. It will be neccesary to provide this when a key was used during the object's creation. If provided one must also include an encryptionKey.

Returns
TypeDescription
string

downloadToFile

Download an object to a specified location.

For an example of setting the range header to download a subrange of the object please see Google\Cloud\Storage\Google\Cloud\Storage\StorageObject::downloadAsStream().

Example:

$stream = $object->downloadToFile(__DIR__ . '/my-file.txt');
Parameters
NameDescription
path string

Path to download the file to.

options array

Configuration Options.

↳ encryptionKey string

An AES-256 customer-supplied encryption key. It will be neccesary to provide this when a key was used during the object's creation. If provided one must also include an encryptionKeySHA256.

↳ encryptionKeySHA256 string

The SHA256 hash of the customer-supplied encryption key. It will be neccesary to provide this when a key was used during the object's creation. If provided one must also include an encryptionKey.

Returns
TypeDescription
Psr\Http\Message\StreamInterface

downloadAsStream

Download an object as a stream. The library will attempt to resume the download if a retry-able error is thrown. An attempt to fetch the remaining file will be made only if the user has not supplied a custom retry function of their own.

Please note Google Cloud Storage respects the Range header as specified by RFC7233. See below for an example of this in action.

Example:

$stream = $object->downloadAsStream();
echo $stream->getContents();
// Set the Range header in order to download a subrange of the object. For more examples of
// setting the Range header, please see [RFC7233](https://tools.ietf.org/html/rfc7233#section-3.1).
$firstFiveBytes = '0-4'; // Get the first 5 bytes.
$fromFifthByteToLastByte = '4-'; // Get the bytes starting with the 5th to the last.
$lastFiveBytes = '-5'; // Get the last 5 bytes.

$stream = $object->downloadAsStream([
    'restOptions' => [
        'headers' => [
            'Range' => "bytes=$firstFiveBytes"
        ]
    ]
]);
Parameters
NameDescription
options array

Configuration Options.

↳ encryptionKey string

An AES-256 customer-supplied encryption key. It will be neccesary to provide this when a key was used during the object's creation. If provided one must also include an encryptionKeySHA256.

↳ encryptionKeySHA256 string

The SHA256 hash of the customer-supplied encryption key. It will be neccesary to provide this when a key was used during the object's creation. If provided one must also include an encryptionKey.

Returns
TypeDescription
Psr\Http\Message\StreamInterface

downloadAsStreamAsync

Asynchronously download an object as a stream.

For an example of setting the range header to download a subrange of the object please see Google\Cloud\Storage\Google\Cloud\Storage\StorageObject::downloadAsStream().

Example:

use Psr\Http\Message\StreamInterface;

$promise = $object->downloadAsStreamAsync()
    ->then(function (StreamInterface $data) {
        echo $data->getContents();
    });

$promise->wait();
// Download all objects in a bucket asynchronously.
use GuzzleHttp\Promise\Utils;
use Psr\Http\Message\StreamInterface;

$promises = [];

foreach ($bucket->objects() as $object) {
    $promises[] = $object->downloadAsStreamAsync()
        ->then(function (StreamInterface $data) {
            echo $data->getContents();
        });
}

Utils::unwrap($promises);
Parameters
NameDescription
options array

Configuration Options.

↳ encryptionKey string

An AES-256 customer-supplied encryption key. It will be neccesary to provide this when a key was used during the object's creation. If provided one must also include an encryptionKeySHA256.

↳ encryptionKeySHA256 string

The SHA256 hash of the customer-supplied encryption key. It will be neccesary to provide this when a key was used during the object's creation. If provided one must also include an encryptionKey.

Returns
TypeDescription
GuzzleHttp\Promise\PromiseInterface<\psr\http\message\streaminterface>

signedUrl

Create a Signed URL for this object.

Signed URLs can be complex, and it is strongly recommended you read and understand the documentation.

In cases where a keyfile is available, signing is accomplished in the client using your Service Account private key. In Google Compute Engine, signing is accomplished using IAM signBlob. Signing using IAM requires that your service account be granted the iam.serviceAccounts.signBlob permission, part of the "Service Account Token Creator" IAM role.

Additionally, signing using IAM requires different scopes. When creating an instance of Google\Cloud\Storage\Google\Cloud\Storage\StorageClient, provide the https://www.googleapis.com/auth/cloud-platform scopein $options.scopes. This scope may be used entirely in place of the scopes provided in Google\Cloud\Storage\Google\Cloud\Storage\StorageClient.

App Engine and Compute Engine will attempt to sign URLs using IAM.

Example:

$url = $object->signedUrl(new \DateTime('tomorrow'));
// Create a signed URL allowing updates to the object.
$url = $object->signedUrl(new \DateTime('tomorrow'), [
    'method' => 'PUT'
]);
// Use Signed URLs v4
$url = $object->signedUrl(new \DateTime('tomorrow'), [
    'version' => 'v4'
]);
// Using Bucket-Bound hostnames
// By default, a custom bucket-bound hostname will use `http` as the schema rather than `https`.
// In order to get an https URI, we need to specify the proper scheme.
$url = $object->signedUrl(new \DateTime('tomorrow'), [
    'version' => 'v4',
    'bucketBoundHostname' => 'cdn.example.com',
    'scheme' => 'https'
]);
// Using virtual hosted style URIs
// When true, returns a URL with the hostname `<bucket>.storage.googleapis.com`.
$url = $object->signedUrl(new \DateTime('tomorrow'), [
    'virtualHostedStyle' => true
]);
Parameters
NameDescription
expires Google\Cloud\Core\Timestamp|DateTimeInterface|int

Specifies when the URL will expire. May provide an instance of Google\Cloud\Storage\Google\Cloud\Core\Timestamp, http://php.net/datetimeimmutable, or a UNIX timestamp as an integer.

options array

Configuration Options.

↳ bucketBoundHostname string

The hostname for the bucket, for instance cdn.example.com. May be used for Google Cloud Load Balancers or for custom bucket CNAMEs. Defaults to storage.googleapis.com.

↳ contentMd5 string

The MD5 digest value in base64. If you provide this, the client must provide this HTTP header with this same value in its request. If provided, take care to always provide this value as a base64 encoded string.

↳ contentType string

If you provide this value, the client must provide this HTTP header set to the same value.

↳ forceOpenssl bool

If true, OpenSSL will be used regardless of whether phpseclib is available. Defaults to false.

↳ headers array

If additional headers are provided, the server will check to make sure that the client provides matching values. Provide headers as a key/value array, where the key is the header name, and the value is an array of header values. Headers with multiple values may provide values as a simple array, or a comma-separated string. For a reference of allowed headers, see Reference Headers. Header values will be trimmed of leading and trailing spaces, multiple spaces within values will be collapsed to a single space, and line breaks will be replaced by an empty string. V2 Signed URLs may not provide x-goog-encryption-key or x-goog-encryption-key-sha256 headers.

↳ keyFile array

Keyfile data to use in place of the keyfile with which the client was constructed. If $options.keyFilePath is set, this option is ignored.

↳ keyFilePath string

A path to a valid Keyfile to use in place of the keyfile with which the client was constructed.

↳ method string

One of GET, PUT or DELETE. Defaults to GET.

↳ responseDisposition string

The response-content-disposition parameter of the signed url.

↳ responseType string

The response-content-type parameter of the signed url. When the server contentType is null, this option may be used to control the content type of the response.

↳ saveAsName string

The filename to prompt the user to save the file as when the signed url is accessed. This is ignored if $options.responseDisposition is set.

↳ scheme string

Either http or https. Only used if a custom hostname is provided via $options.bucketBoundHostname. If a custom bucketBoundHostname is provided, defaults to http. In all other cases, defaults to https.

↳ scopes string|array

One or more authentication scopes to be used with a key file. This option is ignored unless $options.keyFile or $options.keyFilePath is set.

↳ queryParams array

Additional query parameters to be included as part of the signed URL query string. For allowed values, see Reference Headers.

↳ version string

One of "v2" or "v4". Defaults to "v2".

↳ virtualHostedStyle bool

If true, URL will be of form mybucket.storage.googleapis.com. If false, storage.googleapis.com/mybucket. Defaults to false.

Returns
TypeDescription
string

signedUploadUrl

Create a Signed Upload URL for this object.

This method differs from Google\Cloud\Storage\Google\Cloud\Storage\StorageObject::signedUrl() in that it allows you to initiate a new resumable upload session. This can be used to allow non-authenticated users to insert an object into a bucket.

In order to upload data, a session URI must be obtained by sending an HTTP POST request to the URL returned from this method. See the Cloud Storage Documentation for more information.

If you prefer to skip this initial step, you may find Google\Cloud\Storage\Google\Cloud\Storage\StorageObject::beginSignedUploadSession() to fit your needs. Note that beginSignedUploadSession() cannot be used with Google Cloud PHP's Signed URL Uploader, and does not support a configurable expiration date.

Example:

$url = $object->signedUploadUrl(new \DateTime('tomorrow'));
// Use Signed URLs v4
$url = $object->signedUploadUrl(new \DateTime('tomorrow'), [
    'version' => 'v4'
]);
Parameters
NameDescription
expires Google\Cloud\Core\Timestamp|DateTimeInterface|int

Specifies when the URL will expire. May provide an instance of Google\Cloud\Storage\Google\Cloud\Core\Timestamp, http://php.net/datetimeimmutable, or a UNIX timestamp as an integer.

options array

Configuration Options.

↳ contentMd5 string

The MD5 digest value in base64. If you provide this, the client must provide this HTTP header with this same value in its request. If provided, take care to always provide this value as a base64 encoded string.

↳ contentType string

If you provide this value, the client must provide this HTTP header set to the same value.

↳ forceOpenssl bool

If true, OpenSSL will be used regardless of whether phpseclib is available. Defaults to false.

↳ headers array

If additional headers are provided, the server will check to make sure that the client provides matching values. Provide headers as a key/value array, where the key is the header name, and the value is an array of header values. Headers with multiple values may provide values as a simple array, or a comma-separated string. For a reference of allowed headers, see Reference Headers. Header values will be trimmed of leading and trailing spaces, multiple spaces within values will be collapsed to a single space, and line breaks will be replaced by an empty string. V2 Signed URLs may not provide x-goog-encryption-key or x-goog-encryption-key-sha256 headers.

↳ keyFile array

Keyfile data to use in place of the keyfile with which the client was constructed. If $options.keyFilePath is set, this option is ignored.

↳ keyFilePath string

A path to a valid Keyfile to use in place of the keyfile with which the client was constructed.

↳ responseDisposition string

The response-content-disposition parameter of the signed url.

↳ responseType string

The response-content-type parameter of the signed url. When the server contentType is null, this option may be used to control the content type of the response.

↳ saveAsName string

The filename to prompt the user to save the file as when the signed url is accessed. This is ignored if $options.responseDisposition is set.

↳ scheme string

Either http or https. Only used if a custom hostname is provided via $options.bucketBoundHostname. In all other cases, https is used. When a custom bucketBoundHostname is provided, defaults to http.

↳ scopes string|array

One or more authentication scopes to be used with a key file. This option is ignored unless $options.keyFile or $options.keyFilePath is set.

↳ queryParams array

Additional query parameters to be included as part of the signed URL query string. For allowed values, see Reference Headers.

↳ version string

One of "v2" or "v4". Defaults to "v2".

Returns
TypeDescription
string

beginSignedUploadSession

Create a signed URL upload session.

The returned URL differs from the return value of Google\Cloud\Storage\Google\Cloud\Storage\StorageObject::signedUploadUrl() in that it is ready to accept upload data immediately via an HTTP PUT request.

Because an upload session is created by the client, the expiration date is not configurable. The URL generated by this method is valid for one week.

Example:

$url = $object->beginSignedUploadSession();
// Use Signed URLs v4
$url = $object->beginSignedUploadSession([
    'version' => 'v4'
]);
Parameters
NameDescription
options array

Configuration Options.

↳ contentMd5 string

The MD5 digest value in base64. If you provide this, the client must provide this HTTP header with this same value in its request. If provided, take care to always provide this value as a base64 encoded string.

↳ contentType string

If you provide this value, the client must provide this HTTP header set to the same value.

↳ forceOpenssl bool

If true, OpenSSL will be used regardless of whether phpseclib is available. Defaults to false.

↳ headers array

If additional headers are provided, the server will check to make sure that the client provides matching values. Provide headers as a key/value array, where the key is the header name, and the value is an array of header values. Headers with multiple values may provide values as a simple array, or a comma-separated string. For a reference of allowed headers, see Reference Headers. Header values will be trimmed of leading and trailing spaces, multiple spaces within values will be collapsed to a single space, and line breaks will be replaced by an empty string. V2 Signed URLs may not provide x-goog-encryption-key or x-goog-encryption-key-sha256 headers.

↳ keyFile array

Keyfile data to use in place of the keyfile with which the client was constructed. If $options.keyFilePath is set, this option is ignored.

↳ keyFilePath string

A path to a valid Keyfile to use in place of the keyfile with which the client was constructed.

↳ origin string

Value of CORS header "Access-Control-Allow-Origin". Defaults to "*".

↳ scopes string|array

One or more authentication scopes to be used with a key file. This option is ignored unless $options.keyFile or $options.keyFilePath is set.

↳ queryParams array

Additional query parameters to be included as part of the signed URL query string. For allowed values, see Reference Headers.

↳ version string

One of "v2" or "v4". Defaults to "v2".

Returns
TypeDescription
string

info

Retrieves the object's details. If no object data is cached a network request will be made to retrieve it.

Example:

$info = $object->info();
echo $info['size'];
Parameters
NameDescription
options array

Configuration options.

↳ encryptionKey string

An AES-256 customer-supplied encryption key. It will be neccesary to provide this when a key was used during the object's creation in order to retrieve the MD5 hash and CRC32C checksum. If provided one must also include an encryptionKeySHA256.

↳ encryptionKeySHA256 string

The SHA256 hash of the customer-supplied encryption key. It will be neccesary to provide this when a key was used during the object's creation in order to retrieve the MD5 hash and CRC32C checksum. If provided one must also include an encryptionKey.

↳ ifGenerationMatch string

Makes the operation conditional on whether the object's current generation matches the given value.

↳ ifGenerationNotMatch string

Makes the operation conditional on whether the object's current generation does not match the given value.

↳ ifMetagenerationMatch string

Makes the operation conditional on whether the object's current metageneration matches the given value.

↳ ifMetagenerationNotMatch string

Makes the operation conditional on whether the object's current metageneration does not match the given value.

↳ projection string

Determines which properties to return. May be either 'full' or 'noAcl'.

Returns
TypeDescription
array

reload

Triggers a network request to reload the object's details.

Example:

$object->reload();
$info = $object->info();
echo $info['location'];
Parameters
NameDescription
options array

Configuration options.

↳ encryptionKey string

A base64 encoded AES-256 customer-supplied encryption key. It will be neccesary to provide this when a key was used during the object's creation.

↳ encryptionKeySHA256 string

Base64 encoded SHA256 hash of the customer-supplied encryption key. This value will be calculated from the encryptionKey on your behalf if not provided, but for best performance it is recommended to pass in a cached version of the already calculated SHA.

↳ ifGenerationMatch string

Makes the operation conditional on whether the object's current generation matches the given value.

↳ ifGenerationNotMatch string

Makes the operation conditional on whether the object's current generation does not match the given value.

↳ ifMetagenerationMatch string

Makes the operation conditional on whether the object's current metageneration matches the given value.

↳ ifMetagenerationNotMatch string

Makes the operation conditional on whether the object's current metageneration does not match the given value.

↳ projection string

Determines which properties to return. May be either 'full' or 'noAcl'.

Returns
TypeDescription
array

name

Retrieves the object's name.

Example:

echo $object->name();
Returns
TypeDescription
string

identity

Retrieves the object's identity.

Example:

echo $object->identity()['object'];
Returns
TypeDescription
array

gcsUri

Formats the object as a string in the following format: gs://{bucket-name}/{object-name}.

Example:

echo $object->gcsUri();
Returns
TypeDescription
string

Constants

DEFAULT_DOWNLOAD_URL

Value: \Google\Cloud\Storage\SigningHelper::DEFAULT_DOWNLOAD_HOST