Reference documentation and code samples for the Google Cloud PHP shared dependency, providing functionality useful to all components. Client class Blob.
Represents a Blob value.
Blobs can be used to store binary across data various Google Cloud services.
Example:
use Google\Cloud\Core\Blob;
$blob = new Blob(file_get_contents(__DIR__ .'/family-photo.jpg'));
// Get the value of a blob by casting to a string.
echo (string) $blob;
Namespace
Google \ Cloud \ Core
Methods
__construct
Create a blob
Parameter
Name
Description
value
string|resource|Psr\Http\Message\StreamInterface
The blob value
get
Get the blob contents as a stream
Example:
$value = $blob->get();
Returns
Type
Description
Psr\Http\Message\StreamInterface
__toString
Cast the blob to a string
Returns
Type
Description
string
jsonSerialize
Implement JsonSerializable by returning a base64 encoded string of the blob
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[],[],null,["# Google Cloud PHP shared dependency, providing functionality useful to all components. Client - Class Blob (1.64.2)\n\nVersion latestkeyboard_arrow_down\n\n- [1.64.2 (latest)](/php/docs/reference/cloud-core/latest/Blob)\n- [1.64.1](/php/docs/reference/cloud-core/1.64.1/Blob)\n- [1.63.0](/php/docs/reference/cloud-core/1.63.0/Blob)\n- [1.62.3](/php/docs/reference/cloud-core/1.62.3/Blob)\n- [1.61.0](/php/docs/reference/cloud-core/1.61.0/Blob)\n- [1.60.1](/php/docs/reference/cloud-core/1.60.1/Blob)\n- [1.59.1](/php/docs/reference/cloud-core/1.59.1/Blob)\n- [1.58.2](/php/docs/reference/cloud-core/1.58.2/Blob)\n- [1.53.0](/php/docs/reference/cloud-core/1.53.0/Blob)\n- [1.52.11](/php/docs/reference/cloud-core/1.52.11/Blob)\n- [1.51.2](/php/docs/reference/cloud-core/1.51.2/Blob)\n- [1.50.0](/php/docs/reference/cloud-core/1.50.0/Blob)\n- [1.49.3](/php/docs/reference/cloud-core/1.49.3/Blob)\n- [1.48.1](/php/docs/reference/cloud-core/1.48.1/Blob) \nReference documentation and code samples for the Google Cloud PHP shared dependency, providing functionality useful to all components. Client class Blob.\n\nRepresents a Blob value.\n\nBlobs can be used to store binary across data various Google Cloud services.\n\nExample: \n\n use Google\\Cloud\\Core\\Blob;\n\n $blob = new Blob(file_get_contents(__DIR__ .'/family-photo.jpg'));\n\n // Get the value of a blob by casting to a string.\n\n echo (string) $blob;\n\nNamespace\n---------\n\nGoogle \\\\ Cloud \\\\ Core\n\nMethods\n-------\n\n### __construct\n\nCreate a blob\n\n### get\n\nGet the blob contents as a stream\n\nExample: \n\n $value = $blob-\u003eget();\n\n### __toString\n\nCast the blob to a string\n\n### jsonSerialize\n\nImplement JsonSerializable by returning a base64 encoded string of the blob"]]