jeudi 8 août 2019

The 'X-Accel-Redirect' option does not work on Windows

I'm developing on Windows and trying to deploy to Ubuntu. But I found a problem here. If you look at the source code below, it works well on Ubuntu, but on Windows you can see that the file contents are empty. What's the suspected problem?

(The code below can download the file validly. parent == dir, filename == filename + extension)

@login_required
def download_file(request, parent, filename):
    response = HttpResponse()
    response['Content-Disposition'] = 'attachment; filename={0}'.format(filename)
    response['X-Accel-Redirect'] = '/static/download/{0}/{1}'.format(parent,filename)
    print(response['X-Accel-Redirect'])
    return response




Aucun commentaire:

Enregistrer un commentaire