从烧瓶中的GAE blobstore提供blob

时间:2013-05-09 18:12:09

标签: google-app-engine download flask blobstore

我正在尝试使用Flask提供保存在blobstore中的大文件。

对于较小的文件,我可以这样做:

def download_blob(blob_key):
    blob_info = blobstore.get(blob_key)
    response = make_response(blob_info.open().read())
    response.headers['Content-Type'] = blob_info.content_type
    response.headers['Content-Disposition'] = 'attachment; filename="%s"' % blob_info.filename

    return response

但是大文件失败了。如何在不使用webapp2的情况下将BlobstoreDownloadHandler合并到我的Flask应用程序中?

1 个答案:

答案 0 :(得分:2)

如果您不关心范围请求,那么您可以使用blob-key的字符串版本设置“X-AppEngine-BlobKey”标题(或blobstore.BLOB_KEY_HEADER为安全),使用内容类型和处置。

相关问题