当前位置: 首页>>代码示例>>Python>>正文


Python blobstore_handlers.BlobstoreDownloadHandler方法代码示例

本文整理汇总了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) 
开发者ID:GoogleCloudPlatform,项目名称:python-docs-samples,代码行数:24,代码来源:main.py


注:本文中的google.appengine.ext.webapp.blobstore_handlers.BlobstoreDownloadHandler方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。