google/appengine/api/cloud_storage/CloudStorageTools.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\api\cloud_storage\CloudStorageTools
Constants
Methods
createUploadUrl
(string $success_path, mixed[] $options = array())
: string
Create an absolute URL that can be used by a user to asynchronously upload a large blob.
Upon completion of the upload, a callback is made to the specified URL.
Name | Type | Description |
---|---|---|
$success_path | string |
A relative URL which will be invoked after the user successfully uploads a blob. |
$options | mixed[] |
A key value pair array of upload options. Valid options are:
|
Type | Description |
---|---|
string | The upload URL. |
Exception | Description |
---|---|
\InvalidArgumentException | If $success_path is not valid, or one of the options is not valid. |
\google\appengine\api\cloud_storage\CloudStorageException | Thrown when there is a failure using the blobstore service. |
deleteImageServingUrl
(string $gs_filename)
: void
Deletes an image serving URL that was created using getImageServingUrl.
Name | Type | Description |
---|---|---|
$gs_filename | string |
The name of the Google Cloud Storage object that has an existing URL to delete. In the format gs://bucket_name/object_name |
Exception | Description |
---|---|
\InvalidArgumentException | if any of the arguments are not valid. |
\google\appengine\api\cloud_storage\CloudStorageException | If there was a problem contacting the service. |
getContentType
(resource $handle)
: string
Get content type from a Google Cloud Storage file pointer resource.
Name | Type | Description |
---|---|---|
$handle | resource |
A Google Cloud Storage file pointer resource that is typically created using fopen(). |
Type | Description |
---|---|
string | The content type of the Google Cloud Storage object. |
Exception | Description |
---|---|
\InvalidArgumentException | If $handler is not a Google Cloud Storage file pointer resource. |
getDefaultGoogleStorageBucketName
()
: string
Return the name of the default Google Cloud Storage bucket for the application, if one has been configured.
Type | Description |
---|---|
string | The bucket name, or an empty string if no bucket has been configured. |
getFilename
(string $bucket, string $object)
: string
Get the filename of a Google Cloud Storage object.
Name | Type | Description |
---|---|---|
$bucket | string |
The Google Cloud Storage bucket name. |
$object | string |
The Google Cloud Stroage object name. |
Type | Description |
---|---|
string | The filename in the format gs://bucket_name/object_name. |
Exception | Description |
---|---|
\InvalidArgumentException | if bucket or object name is invalid. |
getImageServingUrl
(string $gs_filename, mixed[] $options = array())
: string
Returns a URL that serves an image.
Name | Type | Description |
---|---|---|
$gs_filename | string |
The name of the Google Cloud Storage object to serve. In the format gs://bucket_name/object_name |
$options | mixed[] |
Array of additional options for serving the object. Valid options are:
|
Type | Description |
---|---|
string | The image serving URL. |
Exception | Description |
---|---|
\InvalidArgumentException | if any of the arguments are not valid. |
\google\appengine\api\cloud_storage\CloudStorageException | If there was a problem contacting the service. |
getMetaData
(resource $handle)
: array
Get metadata from a Google Cloud Storage file pointer resource.
Name | Type | Description |
---|---|---|
$handle | resource |
A Google Cloud Storage file pointer resource that is typically created using fopen(). |
Type | Description |
---|---|
array | An array that maps metadata keys to values. |
Exception | Description |
---|---|
\InvalidArgumentException | If $handler is not a Google Cloud Storage file pointer resource. |
getPublicUrl
(string $gs_filename, boolean $use_https)
: string
Get the public URL for a Google Cloud Storage filename.
Name | Type | Description |
---|---|---|
$gs_filename | string |
The Google Cloud Storage filename, in the format gs://bucket_name/object_name. |
$use_https | boolean |
If True then return a HTTPS URL. Note that the development server ignores this argument and returns only HTTP URLs. |
Type | Description |
---|---|
string | The public URL. |
Exception | Description |
---|---|
\InvalidArgumentException | if the filename is not in the correct format or $use_https is not a boolean. |
parseFilename
(string $filename, string $bucket, string $object)
: bool
Parse and extract the bucket and object names from the supplied filename.
Name | Type | Description |
---|---|---|
$filename | string |
The filename in the format gs://bucket_name or gs://bucket_name/object_name. |
$bucket | string |
&$bucket The extracted bucket. |
$object | string |
&$object The extracted bucket. Can be null if the filename contains only bucket name. |
Type | Description |
---|---|
bool | true if the filename is successfully parsed, false otherwise. |
serve
(string $gs_filename, mixed[] $options = array())
: void
Serve a Google Cloud Storage file as the response.
Name | Type | Description |
---|---|---|
$gs_filename | string |
The name of the Google Cloud Storage object to serve. |
$options | mixed[] |
Array of additional options for serving the object.
|
Exception | Description |
---|---|
\InvalidArgumentException | If invalid options are supplied. |
setSendHeaderFunction
(mixed $new_header_func)
: void
This function is used for unit testing only, it allows replacement of the send_header function that is used to set headers on the response.
Name | Type | Description |
---|---|---|
$new_header_func | mixed |
The function to use to set response headers. Set to null to use the inbuilt PHP method header(). |