The
google.appengine.ext.blobstore
package provides several
functions. These functions allow applications to generate upload URLs,
delete blobs, and fetch blob data.
Note: You can use objects stored in Google Cloud Storage with the Blobstore API functions. To do this, you need to generate a Blob Key using the create_gs_key() function.
- create_rpc ( deadline = None , callback = None )
-
Creates and returns an RPC object .
Arguments
- deadline
-
The most amount of time to wait for a response from the remote host, as a number of seconds. If the remote host does not respond in this amount of time, an exception is raised when the
check_success()
method or theget_result()
method of the RPC object is called.If the application attempts to access results before the remote host has responded and before the deadline has elapsed, the call will wait until either of these have occurred, and either return results or raise the exception. If the application request timer expires while the application is waiting, the call is canceled.
- callback
-
A Python function to be called when the service returns results successfully. The function is called without arguments.
The callback function is called when the
wait()
method of the RPC object is called, either directly by the application or implicitly with a call tocheck_success()
orget_result()
. The function does not get called in a background process or thread; it only gets called when one of these methods is called by the application.The callback function is called even if the request fails or if the RPC deadline elapses.
- create_upload_url ( success_path , max_bytes_per_blob = None , max_bytes_total = None , rpc = None , gs_bucket_name = None )
-
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 or to Google Cloud Storage if you use that instead of Blobstore. (Google Cloud Storage requires the
gs_bucket_name
parameter.) 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 application 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.The generated URL will accept a Blobstore upload for up to 10 minutes after it is created. After 10 minutes Blobstore uploads to this URL will be rejected.
Arguments
- success_path
- The URL path of the request handler that will process the upload request, after the file submitted with the form has been uploaded to the Blobstore.
- max_bytes_per_blob
- The maximum size in bytes that any one blob in the upload can be, or None if there is no maximum blob size. Must be a positive value or None.
- max_bytes_total
- The maximum aggregate size of all of the blobs in the upload, or None if there is no total maximum. Must be a positive value or None.
- rpc
-
An RPC object that controls some settings of this request from the application to the Blobstore service (deadline and optional callback function). If this argument is
None
(the default), this request uses normal settings. - gs_bucket_name
-
The Google Storage bucket name that the blob will be stored to. (Required if you use Google Cloud Storage instead of Blobstore.) Your application must have permissions to write to this bucket. Instead of the simple bucket name, you can optionally supply a bucket name and path in the format
bucket_name/path
, in which case the included path will be prepended to the uploaded object name.
Returns the URL to use as the action of an upload form.
- create_upload_url_async ( success_path , max_bytes_per_blob = None , max_bytes_total = None , rpc = None , gs_bucket_name = None )
-
Asynchronously generate an action URL for a Blobstore upload web form. This function is the asynchronous version of
create_upload_url()
.Arguments
- success_path
- The URL path of the request handler that will process the upload request, after the file submitted with the form has been uploaded to the Blobstore.
- max_bytes_per_blob
- The maximum size in bytes that any one blob in the upload can be, or None if there is no maximum blob size. Must be a positive value or None.
- max_bytes_total
- The maximum aggregate size of all of the blobs in the upload, or None if there is no total maximum. Must be a positive value or None.
- rpc
-
An RPC object that controls some settings of this request from the application to the Blobstore service (deadline and optional callback function). If this argument is
None
(the default), this request uses normal settings. - gs_bucket_name
-
The Google Storage bucket name that the blob will be stored to. (Required if you use Google Cloud Storage instead of Blobstore.) Your application must have permissions to write to this bucket. Instead of the simple bucket name, you can optionally supply a bucket name and path in the format
bucket_name/path
, in which case the included path will be prepended to the uploaded object name.
Returns an RPC object. If the
rpc
argument is specified, this return value is that RPC object. This RPC object's result will be the URL to use as the action of an upload form. - delete ( blob_keys , rpc = None )
-
Deletes a value or values from the Blobstore, and the corresponding BlobInfo entities from the datastore.
Arguments
- blob_keys
-
A
BlobKey
object or blob key string, or a list of BlobKey objects or blob key strings to delete. - rpc
-
An RPC object None