【问题标题】:serving blobs from GAE blobstore in flask在烧瓶中提供来自 GAE blobstore 的 blob
【发布时间】:2013-05-04 07:32:03
【问题描述】:

我正在尝试使用 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 应用程序中?

【问题讨论】:

    标签: google-app-engine download flask blobstore


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-11-19
      • 1970-01-01
      • 2012-07-20
      • 1970-01-01
      • 2017-11-01
      • 2015-10-14
      • 2012-09-12
      • 2013-05-11
      相关资源
      最近更新 更多