Minor tweak to determining content type

This commit is contained in:
Trenton Holmes 2022-06-10 08:57:36 -07:00
parent 12cdcf7681
commit b50325c3a3

View File

@ -362,11 +362,12 @@ class DocumentViewSet(
handle = doc.thumbnail_file handle = doc.thumbnail_file
# TODO: Send ETag information and use that to send new thumbnails # TODO: Send ETag information and use that to send new thumbnails
# if available # if available
content_type = ( thumbnail_path = doc.thumbnail_path
"image/webp" if os.path.splitext(thumbnail_path)[1] == ".webp":
if os.path.splitext(doc.thumbnail_path)[1] == ".webp" content_type = "image/webp"
else "image/png" else:
) content_type = "image/png"
return HttpResponse(handle, content_type=content_type) return HttpResponse(handle, content_type=content_type)
except (FileNotFoundError, Document.DoesNotExist): except (FileNotFoundError, Document.DoesNotExist):
raise Http404() raise Http404()