From b50325c3a3822c8463e0483d45573d1f4cb11228 Mon Sep 17 00:00:00 2001 From: Trenton Holmes Date: Fri, 10 Jun 2022 08:57:36 -0700 Subject: [PATCH] Minor tweak to determining content type --- src/documents/views.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/documents/views.py b/src/documents/views.py index 1e9583bc5..bcd2958f8 100644 --- a/src/documents/views.py +++ b/src/documents/views.py @@ -362,11 +362,12 @@ class DocumentViewSet( handle = doc.thumbnail_file # TODO: Send ETag information and use that to send new thumbnails # if available - content_type = ( - "image/webp" - if os.path.splitext(doc.thumbnail_path)[1] == ".webp" - else "image/png" - ) + thumbnail_path = doc.thumbnail_path + if os.path.splitext(thumbnail_path)[1] == ".webp": + content_type = "image/webp" + else: + content_type = "image/png" + return HttpResponse(handle, content_type=content_type) except (FileNotFoundError, Document.DoesNotExist): raise Http404()