Serving Files with Pyramid
Question
I am serving quite large files from a Pyramid Application I have written. My only problem is download managers don't want to play nice.
I can't get resume downloading or segmenting to work with download manager like DownThemAll.
size = os.path.getsize(Path + dFile)
response = Response(content_type='application/force-download', content_disposition='attachment; filename=' + dFile)
response.app_iter = open(Path + dFile, 'rb')
response.content_length = size
I think the problem may lie with paste.httpserver
but I am not sure.
Solution
The web server on the python side needs to support partial downloads, which happens through the HTTP Accept-Ranges header. This blog post digs a bit into this matter with an example in python:
OTHER TIPS
Pyramid 1.3 adds new response classes, FileResponse and FileIter for manually serving files.
Having been working on this problem for a while, I found
http://docs.webob.org/en/latest/file-example.html
to be a great help.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow