本文整理匯總了Python中google.appengine.ext.webapp.blobstore_handlers.BlobstoreDownloadHandler方法的典型用法代碼示例。如果您正苦於以下問題:Python blobstore_handlers.BlobstoreDownloadHandler方法的具體用法?Python blobstore_handlers.BlobstoreDownloadHandler怎麽用?Python blobstore_handlers.BlobstoreDownloadHandler使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類google.appengine.ext.webapp.blobstore_handlers
的用法示例。
在下文中一共展示了blobstore_handlers.BlobstoreDownloadHandler方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get
# 需要導入模塊: from google.appengine.ext.webapp import blobstore_handlers [as 別名]
# 或者: from google.appengine.ext.webapp.blobstore_handlers import BlobstoreDownloadHandler [as 別名]
def get(self):
# Get the default Cloud Storage Bucket name and create a file name for
# the object in Cloud Storage.
bucket = app_identity.get_default_gcs_bucket_name()
# Cloud Storage file names are in the format /bucket/object.
filename = '/{}/blobstore_serving_demo'.format(bucket)
# Create a file in Google Cloud Storage and write something to it.
with cloudstorage.open(filename, 'w') as filehandle:
filehandle.write('abcde\n')
# In order to read the contents of the file using the Blobstore API,
# you must create a blob_key from the Cloud Storage file name.
# Blobstore expects the filename to be in the format of:
# /gs/bucket/object
blobstore_filename = '/gs{}'.format(filename)
blob_key = blobstore.create_gs_key(blobstore_filename)
# BlobstoreDownloadHandler serves the file from Google Cloud Storage to
# your computer using blob_key.
self.send_blob(blob_key)