Python 3.9 is now generally available.

google.appengine.ext.blobstore.BlobReferenceProperty.data_type

Information about blobs in Blobstore.

Inherits From: expected_type

This is a db.Model-like class that contains information about blobs that are stored by an application. Like db.Model, this class is backed by a Datastore entity; however, BlobInfo instances are read-only and have a much more limited interface.

Each BlobInfo has a key of type BlobKey associated with it. This key is specific to the Blobstore API and is not compatible with db.get. The key can be used for quick lookup by passing it to BlobInfo.get. This key converts easily to a string, which is web safe and can be embedded in URLs.

Properties:

  • content_type: The content type of the blob.
  • creation: The creation date of the blob, or when it was uploaded.
  • filename: The file name that the user selected from their machine.
  • size: The size of the uncompressed blob.
  • md5_hash: The MD5 hash value of the uploaded blob.

  • gs_object_name: The name of the object, if the blob is stored in Google Cloud Storage, in the form /[bucket-name]/[object-name]

All properties are read-only. Attempting to assign a value to a property will raise a NotImplementedError.

entity_or_blob_key The datastore entity or blob key that represents the blob reference.
_values Optional; not recommended. This argument passes the associated entity when entity_or_blob_key is a blob key.

content_type Returns the content type of the blob.
creation Returns the creation date or time of upload of the blob.
filename Returns the file name that the user selected from their machine.
gs_object_name

md5_hash Returns the MD5 hash value of the uncompressed blob.
size Returns the size of the uncompressed blob.

Methods

all

View source

Creates a query for all BlobInfo objects associated with the app.

Returns
A db.Query object that queries over BlobInfo's datastore kind.

delete

View source

Permanently deletes a blob from Blobstore.

from_entity

View source

Converts an entity to BlobInfo.

Note:

This method is required for compatibility with the current db.py query mechanism but will be removed in the future. DO NOT USE.

Args
entity The entity that you are trying to convert.

Returns
The BlobInfo that was converted from the entity.

get

View source

Retrieves a BlobInfo by key or by a list of keys.

Args
blob_keys A key or a list of keys. Keys can be in string, Unicode, or BlobKey format.

Returns
A BlobInfo instance that is associated with the provided key or a list of BlobInfo instances if a list of keys was provided. Keys that are not found in Blobstore return None.

gql

View source

Returns a query using a GQL query string.

See the GQL source for more information about GQL.

Args
query_string A properly formatted GQL query string that omits SELECT * FROM <entity>
*args The remaining positional arguments that are used to bind numeric references in the query.
**kwds The dictionary-based arguments for named parameters.

Returns
A gql.GqlQuery object that queries over BlobInfo's datastore kind.

.. _GQL source: https://cloud.google.com/appengine/docs/python/refdocs/google.appengine.ext.gql

key

View source

Gets the key for a blob.

Returns
The BlobKey instance that identifies this blob.

kind

View source

Gets the entity kind for the BlobInfo.

Note:

This method is required for compatibility with the current db.py query mechanism but will be removed in the future. DO NOT USE.

Returns
The entity kind for BlobInfo.

open

View source

Returns a BlobReader for this blob.

Args
*args Arguments to pass to the BlobReader constructor.
**kwargs Keyword arguments to pass to the BlobReader constructor.

Returns
A BlobReader instance.

properties

View source

Defines the set of properties that belong to BlobInfo.

Note:

This method is required for compatibility with the current db.py query mechanism but will be removed in the future. DO NOT USE.

Returns
A set of all of the properties that belong to BlobInfo.