Callhack handler for inspecting our current position in the stream
Returns
Type
Description
int
dir_closedir
Callback handler for trying to close an opened directory.
Returns
Type
Description
bool
dir_opendir
Callback handler for trying to open a directory.
Parameters
Name
Description
path
string
The url directory to open
options
int
Whether or not to enforce safe_mode
Returns
Type
Description
bool
dir_readdir
Callback handler for reading an entry from a directory handle.
Returns
Type
Description
string|bool
dir_rewinddir
Callback handler for rewind the directory handle.
Returns
Type
Description
bool
mkdir
Callback handler for trying to create a directory. If no file path is specified,
or STREAM_MKDIR_RECURSIVE option is set, then create the bucket if it does not exist.
Parameters
Name
Description
path
string
The url directory to create
mode
int
The permissions on the directory
options
int
Bitwise mask of options. STREAM_MKDIR_RECURSIVE
Returns
Type
Description
bool
rename
Callback handler for trying to move a file or directory.
Parameters
Name
Description
from
string
The URL to the current file
to
string
The URL of the new file location
Returns
Type
Description
bool
rmdir
Callback handler for trying to remove a directory or a bucket. If the path is empty
or '/', the bucket will be deleted.
Note that the STREAM_MKDIR_RECURSIVE flag is ignored because the option cannot
be set via thermdir()function.
Parameters
Name
Description
path
string
The URL directory to remove. If the path is empty or is '/',
This will attempt to destroy the bucket.
options
int
Bitwise mask of options.
Returns
Type
Description
bool
stream_cast
Callback handler for retrieving the underlaying resource
Parameter
Name
Description
castAs
int
STREAM_CAST_FOR_SELECT|STREAM_CAST_AS_STREAM
Returns
Type
Description
resource|bool
unlink
Callback handler for deleting a file
Parameter
Name
Description
path
string
The URL of the file to delete
Returns
Type
Description
bool
url_stat
Callback handler for retrieving information about a file
Parameters
Name
Description
path
string
The URI to the file
flags
int
Bitwise mask of options
Returns
Type
Description
array|bool
stream_flush
Callback handler for fflush() function.
Returns
Type
Description
bool
static::register
Register a StreamWrapper for reading and writing to Google Storage
[[["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,["# Cloud Storage Client - Class StreamWrapper (1.48.3)\n\nVersion latestkeyboard_arrow_down\n\n- [1.48.3 (latest)](/php/docs/reference/cloud-storage/latest/StreamWrapper)\n- [1.48.2](/php/docs/reference/cloud-storage/1.48.2/StreamWrapper)\n- [1.47.0](/php/docs/reference/cloud-storage/1.47.0/StreamWrapper)\n- [1.46.0](/php/docs/reference/cloud-storage/1.46.0/StreamWrapper)\n- [1.45.0](/php/docs/reference/cloud-storage/1.45.0/StreamWrapper)\n- [1.44.0](/php/docs/reference/cloud-storage/1.44.0/StreamWrapper)\n- [1.43.1](/php/docs/reference/cloud-storage/1.43.1/StreamWrapper)\n- [1.42.1](/php/docs/reference/cloud-storage/1.42.1/StreamWrapper)\n- [1.41.4](/php/docs/reference/cloud-storage/1.41.4/StreamWrapper)\n- [1.37.0](/php/docs/reference/cloud-storage/1.37.0/StreamWrapper)\n- [1.36.1](/php/docs/reference/cloud-storage/1.36.1/StreamWrapper)\n- [1.35.0](/php/docs/reference/cloud-storage/1.35.0/StreamWrapper)\n- [1.34.0](/php/docs/reference/cloud-storage/1.34.0/StreamWrapper)\n- [1.33.4](/php/docs/reference/cloud-storage/1.33.4/StreamWrapper)\n- [1.32.0](/php/docs/reference/cloud-storage/1.32.0/StreamWrapper)\n- [1.31.2](/php/docs/reference/cloud-storage/1.31.2/StreamWrapper)\n- [1.30.3](/php/docs/reference/cloud-storage/1.30.3/StreamWrapper) \nReference documentation and code samples for the Cloud Storage Client class StreamWrapper.\n\nA streamWrapper implementation for handling `gs://bucket/path/to/file.jpg`.\n\nNote that you can only open a file with mode 'r', 'rb', 'rt', 'w', 'wb', 'wt', 'a', 'ab', or 'at'.\n\nSee: \u003chttp://php.net/manual/en/class.streamwrapper.php\u003e\n\nNamespace\n---------\n\nGoogle \\\\ Cloud \\\\ Storage\n\nMethods\n-------\n\n### __destruct\n\nEnsure we close the stream when this StreamWrapper is destroyed.\n\n### stream_set_option\n\nThis is called when include/require is used on a stream.\n\n### stream_metadata\n\nThis is called when touch is used on a stream. See:\n\u003chttps://www.php.net/manual/en/streamwrapper.stream-metadata.php\u003e\n\n### stream_open\n\nCallback handler for when a stream is opened. For reads, we need to\ndownload the file to see if it can be opened.\n\n### stream_read\n\nCallback handler for when we try to read a certain number of bytes.\n\n### stream_write\n\nCallback handler for when we try to write data to the stream.\n\n### stream_stat\n\nCallback handler for getting data about the stream.\n\n### stream_eof\n\nCallback handler for checking to see if the stream is at the end of file.\n\n### stream_close\n\nCallback handler for trying to close the stream.\n\n### stream_seek\n\nCallback handler for trying to seek to a certain location in the stream.\n\n### stream_tell\n\nCallhack handler for inspecting our current position in the stream\n\n### dir_closedir\n\nCallback handler for trying to close an opened directory.\n\n### dir_opendir\n\nCallback handler for trying to open a directory.\n\n### dir_readdir\n\nCallback handler for reading an entry from a directory handle.\n\n### dir_rewinddir\n\nCallback handler for rewind the directory handle.\n\n### mkdir\n\nCallback handler for trying to create a directory. If no file path is specified,\nor STREAM_MKDIR_RECURSIVE option is set, then create the bucket if it does not exist.\n\n### rename\n\nCallback handler for trying to move a file or directory.\n\n### rmdir\n\nCallback handler for trying to remove a directory or a bucket. If the path is empty\nor '/', the bucket will be deleted.\n\nNote that the STREAM_MKDIR_RECURSIVE flag is ignored because the option cannot\nbe set via the `rmdir()` function.\n\n### stream_cast\n\nCallback handler for retrieving the underlaying resource\n\n### unlink\n\nCallback handler for deleting a file\n\n### url_stat\n\nCallback handler for retrieving information about a file\n\n### stream_flush\n\nCallback handler for fflush() function.\n\n### static::register\n\nRegister a StreamWrapper for reading and writing to Google Storage\n\n### static::unregister\n\nUnregisters the SteamWrapper\n\n### static::getClient\n\nGet the default client to use for streams.\n\nConstants\n---------\n\n### DEFAULT_PROTOCOL\n\n Value: 'gs'\n\n### FILE_WRITABLE_MODE\n\n Value: 33206\n\n### FILE_READABLE_MODE\n\n Value: 33060\n\n### DIRECTORY_WRITABLE_MODE\n\n Value: 16895\n\n### DIRECTORY_READABLE_MODE\n\n Value: 16676\n\n### TAIL_NAME_SUFFIX\n\n Value: '~'"]]