Created on Dec. 1, 2012, 8:10 p.m. by Hevok & updated by Hevok on May 2, 2013, 5:26 p.m.
Apache2 server with xsend file enables to serve files from the file-system:
# views.py
...
import os
from django.http import HttpResponse
from django.contrib.admin.views.decorators import staff_member_required
...
@staff_member_required
def media_xsendfile(request, path, document_root):
response = HttpResponse()
response['Content-Disposition'] = 'attachment'
response['X-Sendfile'] = (os.path.join(document_root, path)).encode('urf-8')
return response
...
# http.conf ... XSendFile on XSendFilePath /path/to/files ...
Comment on This Data Unit