From 772ba2b90971a09eb078cd058b486b131cde4598 Mon Sep 17 00:00:00 2001 From: j Date: Sun, 21 May 2017 23:18:49 +0200 Subject: [PATCH] remove unused file --- pandora/oxdjango/utils.py | 47 --------------------------------------- 1 file changed, 47 deletions(-) delete mode 100644 pandora/oxdjango/utils.py diff --git a/pandora/oxdjango/utils.py b/pandora/oxdjango/utils.py deleted file mode 100644 index 60eb896c..00000000 --- a/pandora/oxdjango/utils.py +++ /dev/null @@ -1,47 +0,0 @@ -# -*- coding: utf-8 -*- -# vi:si:et:sw=4:sts=4:ts=4 -from django.http import HttpResponse,Http404 -from django.core.servers.basehttp import FileWrapper -from django.conf import settings - -import mimetypes -import os - -def basic_sendfile(fname,download_name=None): - if not os.path.exists(fname): - raise Http404 - - wrapper = FileWrapper(open(fname,"r")) - - content_type = mimetypes.guess_type(fname)[0] - response = HttpResponse(wrapper, content_type=content_type) - response['Content-Length'] = os.path.getsize(fname) - - if download_name: - response['Content-Disposition'] = "attachment; filename=%s"%download_name - - return response - -def x_sendfile(fname,download_name=None): - if not os.path.exists(fname): - raise Http404 - - content_type = mimetypes.guess_type(fname)[0] - response = HttpResponse('', content_type=content_type) - response['Content-Length'] = os.path.getsize(fname) - response['X-Sendfile'] = fname - - if download_name: - response['Content-Disposition'] = "attachment; filename=%s"%download_name - - return response - -try: - __sendfile = getattr(settings,'SENDFILE',False) == 'x_sendfile' -except: - __sendfile = False -if __sendfile == 'x_sendfile': - sendfile = x_sendfile -else: - sendfile = basic_sendfile -