用金字塔服务文件

Kra*_*ons 8 python pylons download paste pyramid

我正在为我写过的金字塔应用程序提供相当大的文件.我唯一的问题是下载经理不想玩得好.

我无法获得简历下载或分段以使用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
Run Code Online (Sandbox Code Playgroud)

我认为问题可能存在,paste.httpserver但我不确定.

小智 8

Pyramid 1.3添加了新的响应类,FileResponseFileIter,用于手动提供文件.


mik*_*iku 7

python端的Web服务器需要支持部分下载,这通过HTTP Accept-Ranges标头进行.这个博客文章通过python中的一个例子深入研究了这个问题: