Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/358.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python django多文件下载_Python_Django_Download_Multifile - Fatal编程技术网

Python django多文件下载

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

我的英语不好,因为我来自台湾,所以我会尽量描述我的问题

我使用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

一种方法是创建一个
tarfile
归档文件,并将文件作为单个包发送
. python api是

顺便说一下,这些文件是从多媒体中分离出来的。所以,当我下载这些文件时,我必须合并这些文件