2013-06-06 135 views
0

我的英语不好,因为我来自台湾,所以我会尽力描述我的问题。django多个文件下载

我正在使用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 
+0

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

回答

1

一种方法是创建一个tarfile归档和发送的文件作为一个单一封装 。蟒蛇api是here

+0

谢谢!我会尝试! –