def serve(self, request, path):
fullpath = os.path.join(settings.PRIVATE_MEDIA_ROOT, path)
response = HttpResponse()
response['X-Sendfile'] = fullpath
# From django-filer (https://github.com/stefanfoulis/django-filer/):
# This is needed for lighttpd, hopefully this will
# not be needed after this is fixed:
# http://redmine.lighttpd.net/issues/2076
response['Content-Type'] = mimetypes.guess_type(path)[0] or 'application/octet-stream'
# filename = os.path.basename(path)
# response['Content-Disposition'] = smart_str(u'attachment; filename={0}'.format(filename))
return response
评论列表
文章目录