當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。