![]() |
App Engine Python SDK
v1.6.9 rev.445
The Python runtime is available as an experimental Preview feature.
|
Public Member Functions | |
def | __init__ |
def | abort |
def | store_blob |
def | store_gs_file |
def | store_and_build_forward_message |
def | store_blob_and_transform_request |
def | __call__ |
A WSGI middleware application for handling blobstore upload requests. This application will handle all uploaded files in a POST request, store the results in the blob-storage, close the upload session and forward the request on to another WSGI application, with the environment transformed so that the uploaded file contents are replaced with their blob keys.
def google.appengine.tools.devappserver2.blob_upload.Application.__init__ | ( | self, | |
forward_app, | |||
get_blob_storage = _get_blob_storage , |
|||
generate_blob_key = _generate_blob_key , |
|||
now_func = datetime.datetime.now |
|||
) |
Constructs a new Application. Args: forward_app: A WSGI application to forward successful upload requests to. get_blob_storage: Callable that returns a BlobStorage instance. The default is fine, but may be overridden for testing purposes. generate_blob_key: Function used for generating unique blob keys. now_func: Function that returns the current timestamp.
def google.appengine.tools.devappserver2.blob_upload.Application.__call__ | ( | self, | |
environ, | |||
start_response | |||
) |
Handles WSGI requests. Args: environ: An environ dict for the current request as defined in PEP-333. start_response: A function with semantics defined in PEP-333. Returns: An iterable over strings containing the body of the HTTP response.
def google.appengine.tools.devappserver2.blob_upload.Application.abort | ( | self, | |
code, | |||
detail = None |
|||
) |
Aborts the application by raising a webob.exc.HTTPException. Args: code: HTTP status code int. detail: Optional detail message str. Raises: webob.exc.HTTPException: Always.
def google.appengine.tools.devappserver2.blob_upload.Application.store_and_build_forward_message | ( | self, | |
form, | |||
boundary = None , |
|||
max_bytes_per_blob = None , |
|||
max_bytes_total = None , |
|||
bucket_name = None |
|||
) |
Reads form data, stores blobs data and builds the forward request. This finds all of the file uploads in a set of form fields, converting them into blobs and storing them in the blobstore. It also generates the HTTP request to forward to the user's application. Args: form: cgi.FieldStorage instance representing the whole form derived from original POST data. boundary: The optional boundary to use for the resulting form. If omitted, one is randomly generated. max_bytes_per_blob: The maximum size in bytes that any single blob in the form is allowed to be. max_bytes_total: The maximum size in bytes that the total of all blobs in the form is allowed to be. bucket_name: The name of the Google Storage bucket to store the uploaded files. Returns: A tuple (content_type, content_text), where content_type is the value of the Content-Type header, and content_text is a string containing the body of the HTTP request to forward to the application. Raises: webob.exc.HTTPException: The upload failed.
def google.appengine.tools.devappserver2.blob_upload.Application.store_blob | ( | self, | |
content_type, | |||
filename, | |||
md5_hash, | |||
blob_file, | |||
creation | |||
) |
Store a supplied form-data item to the blobstore. The appropriate metadata is stored into the datastore. Args: content_type: The MIME content type of the uploaded file. filename: The filename of the uploaded file. md5_hash: MD5 hash of the file contents, as a hashlib hash object. blob_file: A file-like object containing the contents of the file. creation: datetime.datetime instance to associate with new blobs creation time. This parameter is provided so that all blobs in the same upload form can have the same creation date. Returns: datastore.Entity('__BlobInfo__') associated with the upload. Raises: _TooManyConflictsError if there were too many name conflicts generating a blob key.
def google.appengine.tools.devappserver2.blob_upload.Application.store_blob_and_transform_request | ( | self, | |
environ | |||
) |
Stores a blob in response to a WSGI request and transforms environ. environ is modified so that it is suitable for forwarding to the user's application. Args: environ: An environ dict for the current request as defined in PEP-333. Raises: webob.exc.HTTPException: The upload failed.
def google.appengine.tools.devappserver2.blob_upload.Application.store_gs_file | ( | self, | |
content_type, | |||
gs_filename, | |||
blob_file, | |||
filename | |||
) |
Store a supplied form-data item to GS. Delegate all the work of gs file creation to CloudStorageStub. Args: content_type: The MIME content type of the uploaded file. gs_filename: The gs filename to create of format bucket/filename. blob_file: A file-like object containing the contents of the file. filename: user provided filename. Returns: datastore.Entity('__GsFileInfo__') associated with the upload.