From: Thomas Fillon Date: Tue, 4 Apr 2017 22:49:18 +0000 (+0200) Subject: Remove unused code X-Git-Tag: search~2^2~19^2~13 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=3c9ab58e48d286c036f8c8695651f5c0eba32794;p=telemeta.git Remove unused code If needed File could be send with Django FileResponse https://docs.djangoproject.com/fr/1.10/ref/request-response/#fileresponse-objects rather than StreamingHttpResponse --- diff --git a/telemeta/views/core.py b/telemeta/views/core.py index 1677d1d8..5c6e0e5a 100644 --- a/telemeta/views/core.py +++ b/telemeta/views/core.py @@ -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,