Change - Serving Media

Created on Dec. 1, 2012, 8:10 p.m. by Hevok & updated on Dec. 1, 2012, 8:10 p.m. by Hevok

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
...
Tags: files django rest
Categories: reST

Comment: Enabled reST.

Comment on This Data Unit