google/appengine/ext/cloud_storage_streams/CloudStorageReadClient.php
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
\google\appengine\ext\cloud_storage_streams\CloudStorageReadClient
Derived classes then only implement the methods that are relevant to the operations that they perform.
Constants
![>](../images/icons/arrow_right.png)
METADATA_HEADER_PREFIX
= 'x-goog-meta-'
![>](../images/icons/arrow_right.png)
DEFAULT_READ_SIZE
= 524288
![>](../images/icons/arrow_right.png)
DEFAULT_READ_CACHE_EXPIRY_SECONDS
= 3600
![>](../images/icons/arrow_right.png)
DEFAULT_MAXIMUM_NUMBER_OF_RETRIES
= 2
![>](../images/icons/arrow_right.png)
DEFAULT_WRITABLE_CACHE_EXPIRY_SECONDS
= 600
![>](../images/icons/arrow_right.png)
READ_SCOPE
= "https://www.googleapis.com/auth/devstorage.read_only"
![>](../images/icons/arrow_right.png)
WRITE_SCOPE
= "https://www.googleapis.com/auth/devstorage.read_write"
![>](../images/icons/arrow_right.png)
FULL_SCOPE
= "https://www.googleapis.com/auth/devstorage.full_control"
![>](../images/icons/arrow_right.png)
OAUTH_TOKEN_FORMAT
= "OAuth %s"
![>](../images/icons/arrow_right.png)
PARTIAL_CONTENT_RANGE_FORMAT
= "bytes %d-%d/*"
![>](../images/icons/arrow_right.png)
FINAL_CONTENT_RANGE_FORMAT
= "bytes %d-%d/%d"
![>](../images/icons/arrow_right.png)
FINAL_CONTENT_RANGE_NO_DATA
= "bytes */%d"
![>](../images/icons/arrow_right.png)
DELIMITER
= '/'
![>](../images/icons/arrow_right.png)
FOLDER_SUFFIX
= '_$folder$'
![>](../images/icons/arrow_right.png)
WRITABLE_TEMP_FILENAME
= "/_ah_is_writable_temp_file"
![>](../images/icons/arrow_right.png)
S_IFREG
= 32768
![>](../images/icons/arrow_right.png)
S_IFDIR
= 16384
![>](../images/icons/arrow_right.png)
S_IRWXU
= 448
![>](../images/icons/arrow_right.png)
S_IRUSR
= 256
![>](../images/icons/arrow_right.png)
S_IWUSR
= 128
![>](../images/icons/arrow_right.png)
S_IXUSR
= 64
![>](../images/icons/arrow_right.png)
S_IRWXG
= 56
![>](../images/icons/arrow_right.png)
S_IRGRP
= 32
![>](../images/icons/arrow_right.png)
S_IWGRP
= 16
![>](../images/icons/arrow_right.png)
S_IXGRP
= 8
![>](../images/icons/arrow_right.png)
S_IRWXO
= 7
![>](../images/icons/arrow_right.png)
S_IROTH
= 4
![>](../images/icons/arrow_right.png)
S_IWOTH
= 2
![>](../images/icons/arrow_right.png)
S_IXOTH
= 1
![>](../images/icons/arrow_right.png)
CONTENT_RANGE_REGEX
= "/bytes\s+(\d+)-(\d+)\/(\d+)/i"
![>](../images/icons/arrow_right.png)
MEMCACHE_KEY_FORMAT
= "_ah_gs_read_cache_%s_%s"
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
![>](../images/icons/arrow_right.png)
WRITABLE_MEMCACHE_KEY_FORMAT
= "_ah_gs_write_bucket_cache_%s"
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.
Methods
![](../images/icons/arrow_right.png)
__construct
(string $bucket, string $object, resource $context)
: void
Construct an object of CloudStorageClient.
Name | Type | Description |
---|---|---|
$bucket | string |
The name of the bucket. |
$object | string |
The name of the object, or null if there is no object. |
$context | resource |
The stream context to use. |
![](../images/icons/arrow_right.png)
createObjectUrl
( $bucket, $object = null)
: void
Create a URL for a target bucket and optional object.
Inherited from: \google\appengine\ext\cloud_storage_streams\CloudStorageClient::createObjectUrl()Name | Type | Description |
---|---|---|
$bucket | ||
$object |
- VisibleForTesting
![](../images/icons/arrow_right.png)
dir_readdir
()
: void
Inherited from: \google\appengine\ext\cloud_storage_streams\CloudStorageClient::dir_readdir()
![](../images/icons/arrow_right.png)
dir_rewinddir
()
: void
Inherited from: \google\appengine\ext\cloud_storage_streams\CloudStorageClient::dir_rewinddir()
![](../images/icons/arrow_right.png)
getContentType
()
: void
Subclass can override this method to return the MIME content type of the underlying GCS object.
![](../images/icons/arrow_right.png)
getMetaData
()
: void
Subclass can override this method to return the metadata of the underlying GCS object.
![](../images/icons/arrow_right.png)
read
( $count_bytes)
: void
Read at most $count_bytes from the file.
If we have reached the end of the buffered amount, and there is more data in the file then retreive more bytes from storage.
Name | Type | Description |
---|---|---|
$count_bytes |
![](../images/icons/arrow_right.png)
seek
( $offset, $whence)
: void
Seek within the current file.
We expect the upper layers of PHP to convert SEEK_CUR to SEEK_SET.
Name | Type | Description |
---|---|---|
$offset | ||
$whence |