How to return multiple FileResponses

Im trying to make a website were the user send me some file, then i do something with this file and then send back to the user. With this need, it will be helpful if i send back multiple files at once, but i don’t know if and how it’s possible.

It’s extremely problematic to try and return multiple files in an html response - different browsers provide different levels of support for doing it.
The safest and most reliable mechanism for returning multiple files is to aggregated them (zip, tar, etc) and return the collection as the single download.

1 Like

I have a method export_excel_file to return excel file as csv/xlsx/xls attachment with response.
Now i want to zip multiple file excel to zip, but i can’t not get two or more file from export_excel_file. What must i do to get zip file through response?

def export_excel_file(request):
    ...
    response = HttpResponse(
        content_type="text/csv",
        headers={"Content-Disposition": 'attachment; filename="detail.csv"'},
    )
    ...
        writer = csv.writer(response)
        writer.writerow(# data of row)

    return response # excel file attached with response