From dbe187e7690f7383cc4736e6a2c2c9d1ff4e67ec Mon Sep 17 00:00:00 2001 From: Guillaume Pellerin Date: Mon, 4 Jun 2018 12:42:05 +0200 Subject: [PATCH] Bugfix, finally fixes #200 --- telemeta/views/core.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 -- 2.39.5