zip_path = os.path.join(zip_subdir, fname)
zf.write(fpath, zip_path)
zf.close()
resp = HttpResponse(s.getvalue(), mimetype='application/x-zip-compressed')
resp['Content-Disposition'] = 'attachment; filename=%s' % zip_filename
return resp
Serving dynamically generated ZIP archives in Django