def bigFileView(request):
u"""在Django中提供大内容(或大文件)下载
@see http://oldj.net/article/django-big-file-response/
"""
# do something...
def readFile(fn, buf_size=262144):
f = open(fn, "rb")
while True:
c = f.read(buf_size)
if c:
yield c
else:
break
f.close()
file_name = "big_file.txt"
response = HttpResponse(readFile(file_name))
return response
Django中提供大内容(或大文件)下载
最新推荐文章于 2022-10-19 10:03:36 发布