This commit is contained in:
Ross
2021-02-17 11:15:14 +00:00
parent 92f569c432
commit 023333523a
+2 -1
View File
@@ -25,7 +25,8 @@ def image_as_base64(image_file):
# encoded_string = base64.b64encode(img_f.read())
encoded_string = base64.b64encode(image_file.file.read())
mimetype, enc = mimetypes.guess_type(image_file.path)
if "dicom" in mimetype or "octet-stream" in mimetype:
# Treat unknown files as dicom
if "dicom" in mimetype or "octet-stream" in mimetype or "None" in mimetype:
return "data:{};base64,{}".format(mimetype, encoded_string.decode("utf-8"))
return "data:image/{};base64,{}".format(mimetype, encoded_string.decode("utf-8"))