django-sendfile with apache2+mod_wsgi: got empty files

32 views
Skip to first unread message

gerard

unread,
Sep 16, 2015, 9:47:55 AM9/16/15
to Django users
Hello all,

im using django-sendfile with django 1.8.4. Tested with development
backend and runserver, everything is fine.
But when going to Apache2 and xsendfile backend, the downloaded files
are empties, i don't understand why.
I have:
MEDIA_ROOT = '/home/devel/media/python3/media'
and Images are in MEDIA_ROOT

In apache2 conf:
<Directory /home/devel/media/python3/media/Images/>
Options Indexes FollowSymLinks MultiViews
XSendFile On
AllowOverride All
Order allow,deny
allow from all
</Directory>

and in views.py, i have:
response = HttpResponse(content_type='application/force-download')
response['Content-Disposition'] = 'attachment;filename="%s"'\
% smart_str(img.name)
response["X-Sendfile"] = img.image.path
response['Content-length'] = img.image.size
return response

Anybody can help?

Thanks in advance,
--
Gérard Henry

gerard

unread,
Sep 16, 2015, 10:11:12 AM9/16/15
to Django users
Le 16/09/2015 15:47, gerard a écrit :
> In apache2 conf:
> <Directory /home/devel/media/python3/media/Images/>
> Options Indexes FollowSymLinks MultiViews
> XSendFile On
> AllowOverride All
> Order allow,deny
> allow from all
> </Directory>
>

ok, replacing the above with:
XSendFile On
XSendFilePath /home/devel/media/python3/media/Images/

does the job. Hope this help,

--
Gérard Henry
Reply all
Reply to author
Forward
0 new messages