Please note that the contents of this offline web site may be out of date. To access the most recent documentation visit the online version .
Note that links that point to online resources are green in color and will open in a new window.
We would love it if you could give us feedback about this material by filling this form (You have to be online to fill it)



google/appengine/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

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

Methods

method public createUploadUrl (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
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:

  • '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
Type Description
string The upload URL.
Throws
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.
method public deleteImageServingUrl (string $gs_filename) : void
static

Deletes an image serving URL that was created using getImageServingUrl.

Parameters
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

Throws
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.
method public getContentType (resource $handle) : string
static

Get content type from a Google Cloud Storage file pointer resource.

Parameters
Name Type Description
$handle resource

A Google Cloud Storage file pointer resource that is typically created using fopen().

Returns
Type Description
string The content type of the Google Cloud Storage object.
Throws
Exception Description
\InvalidArgumentException If $handler is not a Google Cloud Storage file pointer resource.
method public getDefaultGoogleStorageBucketName () : string
static

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

Returns
Type Description
string The bucket name, or an empty string if no bucket has been configured.
method public getFilename (string $bucket, string $object) : string
static

Get the filename of a Google Cloud Storage object.

Parameters
Name Type Description
$bucket string

The Google Cloud Storage bucket name.

$object string

The Google Cloud Stroage object name.

Returns
Type Description
string The filename in the format gs://bucket_name/object_name.
Throws
Exception Description
\InvalidArgumentException if bucket or object name is invalid.
method public getImageServingUrl (string $gs_filename, mixed[] $options = array()) : string
static

Returns a URL that serves an image.

Parameters
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:

  • '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
Type Description
string The image serving URL.
Throws
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.
method public getMetaData (resource $handle) : array
static

Get metadata from a Google Cloud Storage file pointer resource.

Parameters
Name Type Description
$handle resource

A Google Cloud Storage file pointer resource that is typically created using fopen().

Returns
Type Description
array An array that maps metadata keys to values.
Throws
Exception Description
\InvalidArgumentException If $handler is not a Google Cloud Storage file pointer resource.
method public getPublicUrl (string $gs_filename, boolean $use_https) : string
static

Get the public URL for a Google Cloud Storage filename.

Parameters
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.

Returns
Type Description
string The public URL.
Throws
Exception Description
\InvalidArgumentException if the filename is not in the correct format or $use_https is not a boolean.
method public parseFilename (string $filename, string $bucket, string $object) : bool
static

Parse and extract the bucket and object names from the supplied filename.

Parameters
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.

Returns
Type Description
bool true if the filename is successfully parsed, false otherwise.
method public serve (string $gs_filename, mixed[] $options = array()) : void
static

Serve a Google Cloud Storage file as the response.

Parameters
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.

  • '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
Exception Description
\InvalidArgumentException If invalid options are supplied.
method public setSendHeaderFunction (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
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().

Documentation was generated by phpDocumentor 2.0.0a12 .