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()) : stringCreate 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) : voidDeletes 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. |

getDefaultGoogleStorageBucketName() : stringReturn 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) : stringGet 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()) : stringReturns 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. |

getPublicUrl(string $gs_filename, boolean $use_https) : stringGet 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. |

serve(string $gs_filename, mixed[] $options = array()) : voidServe 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) : voidThis 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(). |