本文整理汇总了Python中google.appengine.ext.blobstore.BlobInfo.open方法的典型用法代码示例。如果您正苦于以下问题:Python BlobInfo.open方法的具体用法?Python BlobInfo.open怎么用?Python BlobInfo.open使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类google.appengine.ext.blobstore.BlobInfo
的用法示例。
在下文中一共展示了BlobInfo.open方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: AppEngineUploadedFile
# 需要导入模块: from google.appengine.ext.blobstore import BlobInfo [as 别名]
# 或者: from google.appengine.ext.blobstore.BlobInfo import open [as 别名]
class AppEngineUploadedFile(UploadedFile):
"""
A file uploaded via App Engine's upload mechanism.
"""
def __init__(self, **kwargs):
gs_object_name = kwargs.pop('gs_object_name', None)
blob_key = kwargs.pop('blob_key', None)
if gs_object_name:
self.blobstore_info = CloudStorageInfo(gs_object_name)
elif blob_key:
self.blobstore_info = BlobInfo(blob_key)
else:
raise ValueError('A gs_object_name or blob_key is required.')
super(AppEngineUploadedFile, self).__init__(self.blobstore_info.open(), **kwargs)
def open(self, mode=None):
pass
def chunks(self, chunk_size=1024 * 128):
self.file.seek(0)
while True:
content = self.read(chunk_size)
if not content:
break
yield content
def multiple_chunks(self, chunk_size=1024 * 128):
return True