我正在使用 FileWrapper 下载一个大文件,但我不知道如何在一个响应中下载多个文件。我还可以使用什么其他方法?
try:
mms = message.objects.get(token=token)
except message.DoesNotExist:
return HttpResponse('ret=1&msg=Invalid arguments&')
try:
attach = mms.message_attach_set.get(id = int(attach_id))
except message_attach.DoesNotExist:
return HttpResponse('ret=1&msg=Invalid arguments&')
response = HttpResponse(FileWrapper(attach.file), mimetype='application/force-download')
response['Content-Length'] = str(attach.file.size)
response['X-Sendfile'] = '%s' % (attach.realName)
return response