[Django]-How to send a zip file to frontend to download in DRF

7👍

OK, it turns out it is a little easier than I thought. I could easily do this:

zip_file = open(zip_file_path, 'rb')

response = HttpResponse(zip_file, content_type='application/zip')
response['Content-Disposition'] = 'attachment; filename=name.zip'

return response

0👍

Appending a byte array is assumed to be executed with an integer that will have the value of the appended byte, since append is mostly comprehended as an operation of adding an item to an array, and bytearray is a numerical sequence.

For arrays concatenation, just use the + operator, like strings:

zip_byte_array += byte_content
👤Uriel

Leave a comment