Python django多文件下载
我的英语不好,因为我来自台湾,所以我会尽量描述我的问题 我使用FileWrapper下载一个大文件,但我不知道如何在一个响应中下载多个文件。我还能用什么方法Python django多文件下载,python,django,download,multifile,Python,Django,Download,Multifile,我的英语不好,因为我来自台湾,所以我会尽量描述我的问题 我使用FileWrapper下载一个大文件,但我不知道如何在一个响应中下载多个文件。我还能用什么方法 try: mms = message.objects.get(token=token) except message.DoesNotExist: return HttpResponse('ret=1&msg=Invalid arguments&') try: attach = mms.message
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
一种方法是创建一个
tarfile
归档文件,并将文件作为单个包发送
. python api是顺便说一下,这些文件是从多媒体中分离出来的。所以,当我下载这些文件时,我必须合并这些文件