From: Guillaume Pellerin Date: Mon, 4 Jun 2018 10:42:05 +0000 (+0200) Subject: Bugfix, finally fixes #200 X-Git-Tag: 1.7.0~2^2~4^2~5 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=dbe187e7690f7383cc4736e6a2c2c9d1ff4e67ec;p=telemeta.git Bugfix, finally fixes #200 --- diff --git a/telemeta/views/core.py b/telemeta/views/core.py index 9c075137..b2dd116d 100644 --- a/telemeta/views/core.py +++ b/telemeta/views/core.py @@ -100,7 +100,10 @@ def serve_media(media_path, content_type="", buffering=True, streaming=False): return nginx_media_accel(media_path, content_type=content_type, buffering=buffering, streaming=streaming) else: - response = FileResponse(open(media_path, 'rb')) + try: + response = FileResponse(open(media_path, 'rb')) + except: + response = StreamingHttpResponse(stream_from_file(media_path), content_type=content_type) filename = os.path.basename(media_path) if not streaming: response['Content-Disposition'] = 'attachment; ' + 'filename=' + filename