Google Code offered in: English - Español - 日本語 - 한국어 - Português - Pусский - 中文(简体) - 中文(繁體)
The google.appengine.ext.blobstore package provides the following functions:
Generate an action URL for a Blobstore upload web form.
When the user submits an upload web form, the uploaded data goes directly to the Blobstore. The Blobstore rewrites the incoming request to remove the uploaded data (the MIME part body) and add the Blobstore key (as a header in the MIME part), then passes the rewritten request to the app handler associated with the URL path given to create_upload_url() as success_path. The handler at that path can process the rest of the form, and must return a response with an HTTP redirect code (301, 302, 303).
Arguments:
Returns the URL to use as the action of an upload form.
Deletes a value or values from the Blobstore, and the corresponding BlobInfo entities from the datastore.
Arguments:
This function does not return a value. An app can confirm that a value has been deleted by attempting to get its correpsonding BlobInfo entity using the get() function.
A synonym for BlobInfo.get().
Parses a cgi.FieldStorage object into a BlobInfo object.
When a Blobstore value is uploaded, the Blobstore creates a BlobInfo entity in the datastore. It also retains this data in the headers of the request passed to the upload handler. The upload handler can use parse_blob_info() to access this data from the header instead of making a call to the datastore.
Arguments:
A FieldStorage object, from the cgi module in the Python standard library.
import cgi from google.appengine.ext import blobstore blob_info = blobstore.parse_blob_info(cgi.FieldStorage()) # blob_info.filename...
The argument must be a FieldStorage object that represents a single file upload. If the user request contains more than one file upload (as multipart MIME data), you can iterate over the FieldStorage to get an inner FieldStorage object for each upload, and pass the inner object to the parse_blob_info() function. Here's an example that accommodates multiple files in a single form:
fields = cgi.FieldStorage()
file_fields = fields['file'] # all fields named "file" assumed to contain file uploads
if not isinstance(file_fields, list):
file_fields = [file_fields]
for field in file_fields:
blob_info = blobstore.parse_blob_info(field)
# ...
Retrieves the portion of a given Blobstore value described by the given byte indexes.
The size of the portion (end_index - start_index + 1) must not exceed MAX_BLOB_FETCH_SIZE (about 1 megabyte). fetch_data() allows your app to access data in Blobstore values without exceeding the size limit on API return values.
Returns a str containing the requested portion of the Blobstore value. The return value may contain fewer than end_index - start_index + 1 bytes if either index is larger than the last index of the value.
Byte indexes are inclusive, with the first byte having an index of 0. For example, a start_index of 9 and an end_index of 19 will return up to 11 bytes, starting from the 10th byte (index 9) in the value.
If blob does not refer to an actual Blobstore value, fetch_data raises a ...api.blobstore.BlobNotFoundError.
Arguments:
A BlobInfo object, a BlobKey object, or a str or unicode representation of the blob key for the Blobstore value.
The index of the first byte of the portion of the value to fetch. An index of 0 represents the first byte of the value. If start_index is larger than the last index of the value, fetch_data() returns an empty byte string.
The index of the last byte of the portion of the value to fetch. If end_index is larger than the last index of the value, all bytes from start_index to the end of the value are returned.