gpt4 book ai didi

google-app-engine - 在 flask 中提供来自 GAE blobstore 的 blob

转载 作者:行者123 更新时间:2023-12-03 17:36:45 25 4
gpt4 key购买 nike

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

最佳答案

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

关于google-app-engine - 在 flask 中提供来自 GAE blobstore 的 blob,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16468297/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com