serving blobs from GAE blobstore in flask

谁说胖子不能爱 提交于 2019-12-01 11:08:40

问题


I'm trying to serve big files saved in the blobstore using Flask.

For smaller files I can simply do:

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

but it fails for larger files. How can I incorporate BlobstoreDownloadHandler into my Flask app without resorting back to webapp2?


回答1:


If you don't care about range-requests, then you can just set a header of 'X-AppEngine-BlobKey' (or blobstore.BLOB_KEY_HEADER to be safe) with the string-version of your blob-key, along with the content type and disposition as you have it.



来源:https://stackoverflow.com/questions/16468297/serving-blobs-from-gae-blobstore-in-flask

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!