本文整理汇总了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)