【发布时间】:2010-08-27 08:19:49
【问题描述】:
我正在使用以下 django/python 代码将文件流式传输到浏览器:
wrapper = FileWrapper(file(path))
response = HttpResponse(wrapper, content_type='text/plain')
response['Content-Length'] = os.path.getsize(path)
return response
有没有办法在reponse返回后删除文件?使用回调函数还是什么? 我可以创建一个 cron 来删除所有 tmp 文件,但如果我可以流式传输文件并从同一个请求中删除它们会更整洁。
【问题讨论】: