api/cloud_storage/CloudStorageTools.php

Table of Contents
Copyright 2007 Google Inc.

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

Package: Default
CloudStorageTools allows the user to create and serve data with Google Cloud Storage .

Constants

>VConstant  GS_PREFIX = 'gs://'
>VConstant  BLOB_KEY_HEADER = "X-AppEngine-BlobKey"
>VConstant  BLOB_RANGE_HEADER = "X-AppEngine-BlobRange"
>VConstant  MAX_IMAGE_SERVING_SIZE = 1600
>VConstant  LOCAL_ENDPOINT = "/_ah/gcs"
>VConstant  PRODUCTION_HOST = "storage.googleapis.com"
>VConstant  GS_FILENAME_FORMAT = "gs://%s/%s"

Methods

methodpubliccreateUploadUrl(string $success_path, mixed[] $options = array()) : string
static

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.

Parameters
NameTypeDescription
$success_pathstring

A relative URL which will be invoked after the user successfully uploads a blob.

$optionsmixed[]

A key value pair array of upload options. Valid options are:

  • 'max_bytes_per_blob': integer The value of the largest size that any one uploaded blob may be. Default value: unlimited.
  • 'max_bytes_total': integer The value that is the total size that sum of all uploaded blobs may be. Default value: unlimited.
  • 'gs_bucket_name': string The name of a Google Cloud Storage bucket that the blobs should be uploaded to. Not specifying a value will result in the blob being uploaded to the application's default bucket.
Returns
TypeDescription
stringThe upload URL.
Throws
ExceptionDescription
\InvalidArgumentExceptionIf $success_path is not valid, or one of the options is not valid.
\google\appengine\api\cloud_storage\CloudStorageExceptionThrown when there is a failure using the blobstore service.
methodpublicdeleteImageServingUrl(string $gs_filename) : void
static

Deletes an image serving URL that was created using getImageServingUrl.

Parameters
NameTypeDescription
$gs_filenamestring

The name of the Google Cloud Storage object that has an existing URL to delete. In the format gs://bucket_name/object_name

Throws
ExceptionDescription
\InvalidArgumentExceptionif any of the arguments are not valid.
\google\appengine\api\cloud_storage\CloudStorageExceptionIf there was a problem contacting the service.
methodpublicgetDefaultGoogleStorageBucketName() : string
static

Return the name of the default Google Cloud Storage bucket for the application, if one has been configured.

Returns
TypeDescription
stringThe bucket name, or an empty string if no bucket has been configured.
methodpublicgetFilename(string $bucket, string $object) : string
static

Get the filename of a Google Cloud Storage object.

Parameters
NameTypeDescription
$bucketstring

The Google Cloud Storage bucket name.

$objectstring

The Google Cloud Stroage object name.

Returns
TypeDescription
stringThe filename in the format gs://bucket_name/object_name.
Throws
ExceptionDescription
\InvalidArgumentExceptionif bucket or object name is invalid.
methodpublicgetImageServingUrl(string $gs_filename, mixed[] $options = array()) : string
static

Returns a URL that serves an image.

Parameters
NameTypeDescription
$gs_filenamestring

The name of the Google Cloud Storage object to serve. In the format gs://bucket_name/object_name

$optionsmixed[]

Array of additional options for serving the object. Valid options are:

  • 'crop': boolean Whether the image should be cropped. If set to true, a size must also be supplied. Default value: false.
  • 'secure_url': boolean Whether to request an https URL. Default value: false.
  • 'size': integer The size of the longest dimension of the resulting image. Size must be in the range 0 to 1600, with 0 specifying the size of the original image. The aspect ratio is preserved unless 'crop' is specified.
Returns
TypeDescription
stringThe image serving URL.
Throws
ExceptionDescription
\InvalidArgumentExceptionif any of the arguments are not valid.
\google\appengine\api\cloud_storage\CloudStorageExceptionIf there was a problem contacting the service.
methodpublicgetPublicUrl(string $gs_filename, boolean $use_https) : string
static

Get the public URL for a Google Cloud Storage filename.

Parameters
NameTypeDescription
$gs_filenamestring

The Google Cloud Storage filename, in the format gs://bucket_name/object_name.

$use_httpsboolean

If True then return a HTTPS URL. Note that the development server ignores this argument and returns only HTTP URLs.

Returns
TypeDescription
stringThe public URL.
Throws
ExceptionDescription
\InvalidArgumentExceptionif the filename is not in the correct format or $use_https is not a boolean.
methodpublicserve(string $gs_filename, mixed[] $options = array()) : void
static

Serve a Google Cloud Storage file as the response.

Parameters
NameTypeDescription
$gs_filenamestring

The name of the Google Cloud Storage object to serve.

$optionsmixed[]

Array of additional options for serving the object.

  • 'content_type': string Content-Type to override when known.
  • 'save_as': boolean If True then send the file as an attachment.
  • 'start': int Start index of content-range to send.
  • 'end': int End index of content-range to send. End index is inclusive.
  • 'use_range': boolean Use provided content range from the request's Range header. Mutually exclusive with start and end.
Throws
ExceptionDescription
\InvalidArgumentExceptionIf invalid options are supplied.
methodpublicsetSendHeaderFunction(mixed $new_header_func) : void
static

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.

Parameters
NameTypeDescription
$new_header_funcmixed

The function to use to set response headers. Set to null to use the inbuilt PHP method header().

Documentation was generated by phpDocumentor 2.0.0a12.