\google\appengine\ext\cloud_storage_streams\CloudStorageDirectoryClient

FINAL

Cloud Storage Directory Client handles dir_opendir(), dir_readdir() and dir_closedir() calls for Google Cloud Storage bucket.

CloudStorageClient provides default fail implementations for all of the methods that the stream wrapper might potentially call. Derived classes then only implement the methods that are relevant to the operations that they perform.

Constants

METADATA_HEADER_PREFIX

Prefix for all metadata headers used when parsing and rendering.

Inherited from

\google\appengine\ext\cloud_storage_streams\CloudStorageClient

DEFAULT_READ_SIZE

Inherited from

\google\appengine\ext\cloud_storage_streams\CloudStorageClient

DEFAULT_READ_CACHE_EXPIRY_SECONDS

Inherited from

\google\appengine\ext\cloud_storage_streams\CloudStorageClient

DEFAULT_MAXIMUM_NUMBER_OF_RETRIES

Inherited from

\google\appengine\ext\cloud_storage_streams\CloudStorageClient

DEFAULT_CONNECTION_TIMEOUT_SECONDS

Inherited from

\google\appengine\ext\cloud_storage_streams\CloudStorageClient

DEFAULT_WRITABLE_CACHE_EXPIRY_SECONDS

Inherited from

\google\appengine\ext\cloud_storage_streams\CloudStorageClient

READ_SCOPE

Inherited from

\google\appengine\ext\cloud_storage_streams\CloudStorageClient

WRITE_SCOPE

Inherited from

\google\appengine\ext\cloud_storage_streams\CloudStorageClient

FULL_SCOPE

Inherited from

\google\appengine\ext\cloud_storage_streams\CloudStorageClient

OAUTH_TOKEN_FORMAT

Inherited from

\google\appengine\ext\cloud_storage_streams\CloudStorageClient

PARTIAL_CONTENT_RANGE_FORMAT

Inherited from

\google\appengine\ext\cloud_storage_streams\CloudStorageClient

FINAL_CONTENT_RANGE_FORMAT

Inherited from

\google\appengine\ext\cloud_storage_streams\CloudStorageClient

FINAL_CONTENT_RANGE_NO_DATA

Inherited from

\google\appengine\ext\cloud_storage_streams\CloudStorageClient

DELIMITER

Inherited from

\google\appengine\ext\cloud_storage_streams\CloudStorageClient

FOLDER_SUFFIX

Inherited from

\google\appengine\ext\cloud_storage_streams\CloudStorageClient

WRITABLE_TEMP_FILENAME

Inherited from

\google\appengine\ext\cloud_storage_streams\CloudStorageClient

S_IFREG

Inherited from

\google\appengine\ext\cloud_storage_streams\CloudStorageClient

S_IFDIR

Inherited from

\google\appengine\ext\cloud_storage_streams\CloudStorageClient

S_IRWXU

Inherited from

\google\appengine\ext\cloud_storage_streams\CloudStorageClient

S_IRUSR

Inherited from

\google\appengine\ext\cloud_storage_streams\CloudStorageClient

S_IWUSR

Inherited from

\google\appengine\ext\cloud_storage_streams\CloudStorageClient

S_IXUSR

Inherited from

\google\appengine\ext\cloud_storage_streams\CloudStorageClient

S_IRWXG

Inherited from

\google\appengine\ext\cloud_storage_streams\CloudStorageClient

S_IRGRP

Inherited from

\google\appengine\ext\cloud_storage_streams\CloudStorageClient

S_IWGRP

Inherited from

\google\appengine\ext\cloud_storage_streams\CloudStorageClient

S_IXGRP

Inherited from

\google\appengine\ext\cloud_storage_streams\CloudStorageClient

S_IRWXO

Inherited from

\google\appengine\ext\cloud_storage_streams\CloudStorageClient

S_IROTH

Inherited from

\google\appengine\ext\cloud_storage_streams\CloudStorageClient

S_IWOTH

Inherited from

\google\appengine\ext\cloud_storage_streams\CloudStorageClient

S_IXOTH

Inherited from

\google\appengine\ext\cloud_storage_streams\CloudStorageClient

CONTENT_RANGE_REGEX

Inherited from

\google\appengine\ext\cloud_storage_streams\CloudStorageClient

MEMCACHE_KEY_FORMAT

Memcache key format for caching the results of reads from GCS. The parameters are the object url (as a string) and the read range, as a string (e.g. bytes=0-512000).

Example key for a cloud storage file gs://bucket/object.png _ah_gs_read_cache_https://storage.googleapis.com/bucket/object.png_bytes=0-524287

Inherited from

\google\appengine\ext\cloud_storage_streams\CloudStorageClient

MEMCACHE_KEY_HASH_FORMAT

Memcache key format for caching the results of reads from GCS. If the key generated using the filename and range is longer than the maximum allowed memcache key we hash down the value and use this format instead.

Inherited from

\google\appengine\ext\cloud_storage_streams\CloudStorageClient

MEMCACHE_KEY_MAX_LENGTH

The maximum length of a memcache key.

Inherited from

\google\appengine\ext\cloud_storage_streams\CloudStorageClient

WRITABLE_MEMCACHE_KEY_FORMAT

Memcache key format for caching the results of checking if a bucket is writable. The only way to check if an app can write to a bucket is by actually writing a file. As the ACL on a bucket is unlikely to change then we can cache the result.

Inherited from

\google\appengine\ext\cloud_storage_streams\CloudStorageClient

MAX_KEYS

Methods

__construct

__construct(string $bucket_name, string $object_name, mixed $context)

Class constructor.

Parameters

Name Description

$bucket_name

string

The name of the bucket.

$object_name

string

The name of the object.

$context

mixed

The stream context for this operation.

__destruct

__destruct()

Inherited from

\google\appengine\ext\cloud_storage_streams\CloudStorageClient

initialize

initialize()

Inherited from

\google\appengine\ext\cloud_storage_streams\CloudStorageClient

dir_readdir

dir_readdir() : string

Read the next file in the directory list. If the list is empty and we believe that there are more results to read then fetch them

Returns

string

The name of the next file in the directory, false if there are not more files.

dir_rewinddir

dir_rewinddir() : boolean

Rewind the directory handle to the first file that would have been returned from opendir().

Returns

boolean

true is successful, false otherwise.

close

close()

Close the directory handle.

delete

delete()

Inherited from

\google\appengine\ext\cloud_storage_streams\CloudStorageClient

eof

eof()

Inherited from

\google\appengine\ext\cloud_storage_streams\CloudStorageClient

flush

flush()

Inherited from

\google\appengine\ext\cloud_storage_streams\CloudStorageClient

read

read( $count_bytes)

Parameters

Name Description

$count_bytes

Inherited from

\google\appengine\ext\cloud_storage_streams\CloudStorageClient

seek

seek( $offset, $whence)

Parameters

Name Description

$offset

$whence

Inherited from

\google\appengine\ext\cloud_storage_streams\CloudStorageClient

stat

stat()

Inherited from

\google\appengine\ext\cloud_storage_streams\CloudStorageClient

tell

tell()

Inherited from

\google\appengine\ext\cloud_storage_streams\CloudStorageClient

write

write( $data)

Parameters

Name Description

$data

Inherited from

\google\appengine\ext\cloud_storage_streams\CloudStorageClient

getMetaData

getMetaData()

Subclass can override this method to return the metadata of the underlying GCS object.

Inherited from

\google\appengine\ext\cloud_storage_streams\CloudStorageClient

getContentType

getContentType()

Subclass can override this method to return the MIME content type of the underlying GCS object.

Inherited from

\google\appengine\ext\cloud_storage_streams\CloudStorageClient

createObjectUrl

STATIC   

createObjectUrl( $bucket, $object = null)

Create a URL for a target bucket and optional object.

Parameters

Name Description

$bucket

$object

Inherited from

\google\appengine\ext\cloud_storage_streams\CloudStorageClient

clearStatCache

STATIC   

clearStatCache(string $filename = null)

Clear the stat cache.

Parameters

Name Description

$filename

string

Option filename to clear from the cache.

Inherited from

\google\appengine\ext\cloud_storage_streams\CloudStorageClient

getReadMemcacheKey

STATIC   

getReadMemcacheKey(string $url, string $range) : string

Create a memcache key for the read data cache. If the filename is long enough that the key would exceed memcache limits, then a hash of the filename and the range is used to generate the key.

We prefer the human readable key format where possible so users can easily identify which files and segments are stored in memcache.

Parameters

Name Description

$url

string

The url of the file that contains the data being cached.

$range

string

The range oheader f the data being cached.

Returns

string

The memcache key to use for storing data.

Inherited from

\google\appengine\ext\cloud_storage_streams\CloudStorageClient

initialise

initialise() : boolean

Make the initial connection to GCS and fill the read buffer with files.

Returns

boolean

true if we can connect to the Cloud Storage bucket, false otherwise.

mkdir

mkdir(mixed $options) : boolean

Make a 'directory' in Google Cloud Storage.

Parameters

Name Description

$options

mixed

A bitwise mask of values, such as STREAM_MKDIR_RECURSIVE.

Returns

boolean

true if the directory was created, false otherwise.

TODO: If the STREAM_MKDIR_RECURSIVE bit is not set in the options then we should validate that the entire path exists before we create the directory.

rmdir

rmdir(mixed $options) : boolean

Attempts to remove the directory . The directory must be empty. A E_WARNING level error will be generated on failure.

Parameters

Name Description

$options

mixed

A bitwise mask of values, such as STREAM_MKDIR_RECURSIVE.

Returns

boolean

true if the directory was removed, false otherwise.