fix: return binary if not image type, not crash e.g. on svg
This commit is contained in:
parent
162f8a50a9
commit
bd5cbd3394
|
|
@ -34,6 +34,8 @@ def user_image(request, image_id):
|
|||
|
||||
rendition.file.open("rb")
|
||||
image_format = imghdr.what(rendition.file)
|
||||
|
||||
return StreamingHttpResponse(
|
||||
FileWrapper(rendition.file), content_type="image/" + image_format
|
||||
FileWrapper(rendition.file),
|
||||
content_type=f"image/{image_format}" if image_format else "binary/octet-stream",
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in New Issue