google.appengine.api.blobstore.blobstore module

Summary

Blobstore API.

This module contains methods that you can use to interface with the Blobstore API. The module defines a db.Key-like class that represents a blob key.

Contents

exception google.appengine.api.blobstore.blobstore.BlobFetchSizeTooLargeErrorsource

Bases: google.appengine.api.blobstore.blobstore.Error

The block could not be fetched because it was too large.

class google.appengine.api.blobstore.blobstore.BlobKey(blob_key)source

Bases: object

Key used to identify a blob in Blobstore.

This object wraps a string that gets used internally by the Blobstore API to identify application blobs. The BlobKey corresponds to the entity name of the underlying BlobReference entity.

This class is exposed in the API in both google.appengine.ext.db and google.appengine.ext.blobstore.

ToXml()source
exception google.appengine.api.blobstore.blobstore.BlobNotFoundErrorsource

Bases: google.appengine.api.blobstore.blobstore.Error

The blob does not exist.

exception google.appengine.api.blobstore.blobstore.DataIndexOutOfRangeErrorsource

Bases: google.appengine.api.blobstore.blobstore.Error

The indexes could not be accessed.

The specified indexes were out of range or in the wrong order.

exception google.appengine.api.blobstore.blobstore.PermissionDeniedErrorsource

Bases: google.appengine.api.blobstore.blobstore.Error

The operation did not complete; review the permissions required.

exception google.appengine.api.blobstore.blobstore.Errorsource

Bases: exceptions.Exception

Base blobstore error type.

exception google.appengine.api.blobstore.blobstore.InternalErrorsource

Bases: google.appengine.api.blobstore.blobstore.Error

An internal error occured.

google.appengine.api.blobstore.blobstore.create_rpc(deadline=None, callback=None)source

Creates an RPC object to use with the Blobstore API.

Parameters
  • deadline -- Optional deadline in seconds for the operation; the default value is a system-specific deadline, typically 5 seconds.

  • callback -- Optional callable to invoke on completion.

Returns

An apiproxy_stub_map.UserRPC object that is specialized for this service.

google.appengine.api.blobstore.blobstore.create_upload_url(success_path, max_bytes_per_blob=None, max_bytes_total=None, rpc=None, gs_bucket_name=None)source

Creates the upload URL for a POST form.

Parameters
  • success_path -- Path within application to call when a POST call is successful and the upload is complete.

  • max_bytes_per_blob -- The maximum size in bytes that any one blob in the upload can be, or None for no maximum size.

  • max_bytes_total -- The maximum size in bytes that the aggregate sizes of all of the blobs in the upload can be, or None for no maximum size.

  • rpc -- Optional UserRPC object.

  • gs_bucket_name -- The Google Cloud Storage bucket name to which the blobs should be uploaded. The application's service account must have the correct permissions to write to this bucket. The bucket name can be of the format bucket/path/, in which case the included path will be prepended to the uploaded object name.

Returns

The upload URL.

Raises
  • TypeError -- If max_bytes_per_blob or max_bytes_total are not integral types.

  • ValueError -- If max_bytes_per_blob or max_bytes_total are not positive values.

google.appengine.api.blobstore.blobstore.create_upload_url_async(success_path, max_bytes_per_blob=None, max_bytes_total=None, rpc=None, gs_bucket_name=None)source

Asynchronously creates the upload URL for a POST form.

Parameters
  • success_path -- The path within the application to call when a POST call is successful and the upload is complete.

  • max_bytes_per_blob -- The maximum size in bytes that any one blob in the upload can be, or None for no maximum size.

  • max_bytes_total -- The maximum size in bytes that the aggregate sizes of all of the blobs in the upload can be, or None for no maximum size.

  • rpc -- Optional UserRPC object.

  • gs_bucket_name -- The Google Cloud Storage bucket name to which the blobs should be uploaded. The application's service account must have the correct permissions to write to this bucket. The bucket name can be of the format bucket/path/, in which case the included path will be prepended to the uploaded object name.

Returns

A UserRPC whose result will be the upload URL.

Raises
  • TypeError -- If max_bytes_per_blob or max_bytes_total are not integral types.

  • ValueError -- If max_bytes_per_blob or max_bytes_total are not positive values.

google.appengine.api.blobstore.blobstore.delete(blob_keys, rpc=None, _token=None)source

Deletes a blob from Blobstore.

Parameters
  • blob_keys -- A single BlobKey instance or a list of blob keys. A blob key can be either a string or an instance of BlobKey.

  • rpc -- Optional UserRPC object.

Returns

None.

google.appengine.api.blobstore.blobstore.delete_async(blob_keys, rpc=None, _token=None)source

Asynchronously deletes a blob from Blobstore.

Parameters
  • blob_keys -- A single BlobKey instance or a list of blob keys. A blob key can be either a string or an instance of BlobKey.

  • rpc -- Optional UserRPC object.

Returns

A UserRPC, whose result will be None.

google.appengine.api.blobstore.blobstore.fetch_data(blob_key, start_index, end_index, rpc=None)source

Fetches the data for a blob.

Parameters
  • blob_key -- A BlobKey, string, or Unicode representation of a BlobKey of the blob from which you want to fetch data.

  • start_index -- The start index value of the blob data to fetch. This argument cannot be set to a negative value.

  • end_index -- The end index value (exclusive) of the blob data to fetch. This argument must be greater than or equal to the start_index value.

  • rpc -- Optional UserRPC object.

Returns

A string containing partial data of the blob.

google.appengine.api.blobstore.blobstore.fetch_data_async(blob_key, start_index, end_index, rpc=None)source

Asynchronously fetches the data for a blob.

Parameters
  • blob_key -- A BlobKey, string, or Unicode representation of a BlobKey of the blob from which you want to fetch data.

  • start_index -- The start index value of the blob data to fetch. This argument cannot be set to a negative value.

  • end_index -- The end index value (exclusive) of the blob data to fetch. This argument must be greater than or equal to the start_index value.

  • rpc -- Optional UserRPC object.

Returns

A UserRPC whose result will be a string as returned by fetch_data().

google.appengine.api.blobstore.blobstore.create_gs_key(filename, rpc=None)source

Creates an encoded key for a Google Cloud Storage file.

It is safe to persist this key for future use.

Parameters
  • filename -- The file name of the Google Cloud Storage object for which you want to create the key.

  • rpc -- Optional UserRPC object.

Returns

An encrypted BlobKey string.

google.appengine.api.blobstore.blobstore.create_gs_key_async(filename, rpc=None)source

Asynchronously creates an encoded key for a Google Cloud Storage file.

It is safe to persist this key for future use.

Parameters
  • filename -- The file name of the Google Cloud Storage object for which you want to create the key.

  • rpc -- Optional UserRPC object.

Returns

A UserRPC whose result will be a string as returned by create_gs_key().

Raises
  • TypeError -- If filename is not a string.

  • ValueError -- If filename is not in the format /gs/bucket_name/object_name.

Send feedback about...

App Engine standard environment for Python