]> git.parisson.com Git - telemeta.git/commitdiff
Remove unused code
authorThomas Fillon <thomas@parisson.com>
Tue, 4 Apr 2017 22:49:18 +0000 (00:49 +0200)
committerThomas Fillon <thomas@parisson.com>
Tue, 4 Apr 2017 22:49:18 +0000 (00:49 +0200)
If needed File could be send with Django FileResponse https://docs.djangoproject.com/fr/1.10/ref/request-response/#fileresponse-objects rather than StreamingHttpResponse

telemeta/views/core.py

index 1677d1d8a851043a48a8a2ef3a4dc8d1b4833620..5c6e0e5a6c2e8f380b5fe313f607f59feccef8c0 100644 (file)
@@ -57,7 +57,6 @@ from django.utils.translation import ugettext
 from django.contrib.auth.forms import UserChangeForm
 from django.core.exceptions import ObjectDoesNotExist
 from django.contrib.syndication.views import Feed
-from django.core.servers.basehttp import FileWrapper
 from django.core.urlresolvers import reverse, reverse_lazy
 from django.contrib.contenttypes.models import ContentType
 from django.views.decorators.http import condition
@@ -96,25 +95,6 @@ class TelemetaBaseMixin(object):
     cache_tmp = TelemetaCache(getattr(settings, 'FILE_UPLOAD_TEMP_DIR', os.path.join(MEDIA_ROOT, 'tmp')))
 
 
-class FixedFileWrapper(FileWrapper):
-
-    def __iter__(self):
-        self.filelike.seek(0)
-        return self
-
-
-def send_file(request, filename, content_type='image/jpeg'):
-    """
-    Send a file through Django without loading the whole file into
-    memory at once. The FileWrapper will turn the file object into an
-    iterator for chunks of 8KB.
-    """
-    wrapper = FixedFileWrapper(file(filename, 'rb'))
-    response = StreamingHttpResponse(wrapper, content_type=content_type)
-    response['Content-Length'] = os.path.getsize(filename)
-    return response
-
-
 def serve_media(filename, content_type="", buffering=True):
     if True:
         return nginx_media_accel(filename, content_type=content_type,