2

Is there a way to download multiple files in Django without creating zipfile on single click/request. For downloading single file I am using the following code in views.py:

def download_file(request):
   the_file = '/some/file/name.png'
   filename = os.path.basename(the_file)
   chunk_size = 8192
   response = StreamingHttpResponse(FileWrapper(open(the_file, 'rb'), chunk_size),
                           content_type=mimetypes.guess_type(the_file)[0])
   response['Content-Length'] = os.path.getsize(the_file)    
   response['Content-Disposition'] = "attachment; filename=%s" % filename
   return response
Also the code should be capable of downloading large files in size of 100GB max as I am dealing with video files with high resolution
Heikura
  • 1,009
  • 3
  • 13
  • 27

0 Answers0