【问题标题】:Django multiple file downloadDjango 多文件下载
【发布时间】:2013-06-06 01:15:54
【问题描述】:

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

【问题讨论】:

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

标签: python django download


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-02-16
    • 1970-01-01
    • 1970-01-01
    • 2019-04-09
    • 2013-03-25
    • 2013-04-06
    • 2011-03-09
    相关资源
    最近更新 更多