An instance of the
BlobKey
class represents the key of a Blobstore value. This value can be stored as a property value in a datastore entity, used to get the
BlobInfo
object that corresponds with a Blobstore value, and returned in a response header to serve the Blobstore value to a user.
The
BlobKey
class is provided by the
google.appengine.ext.blobstore
module.
Your Blobstore upload handler can access the string form of the Blobstore key in the request data, as the
X-AppEngine-BlobKey
header in the MIME part that corresponds with the uploaded file. You can convert this string to a
BlobKey
value by passing the string to the
BlobKey()
constructor.
You can get the string form of a
BlobKey
value by passing it to the
str()
builtin. The string form avoids special characters used in URLs and HTML, so it can be used in user-facing data without being escaped. A Blobstore value can only be retrieved by a user if the application sets the
X-AppEngine-BlobKey
header in a response, so the application can control access to values even if Blobstore keys are public. If access to your Blobstore values must be restricted, be careful when serving values based on keys calculated from user-submitted data.
You can use the
BlobReferenceProperty
class with
the Python data modeling interface
to create references to BlobInfo entities from other entities. The actual value stored for the property is a BlobKey value.
You can fetch the
BlobInfo
entity with a
BlobKey
by passing the key to the
BlobInfo.get()
class method.