[#2497] Fix for png media proxy preview response headers (content-type & content-disposition).
This commit is contained in:
parent
0a839d51a7
commit
6ce28c4091
|
@ -67,7 +67,7 @@ defp handle_preview(conn, url) do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# TODO: find a workaround so avatar_static and banner_static can work.
|
# TODO: find a workaround so avatar_static and header_static can work.
|
||||||
# Those only permit GIFs for animation, so we have to permit a way to
|
# Those only permit GIFs for animation, so we have to permit a way to
|
||||||
# allow those to get real static variants.
|
# allow those to get real static variants.
|
||||||
defp handle_preview("image/gif" = _content_type, conn, url) do
|
defp handle_preview("image/gif" = _content_type, conn, url) do
|
||||||
|
@ -107,7 +107,7 @@ defp handle_png_preview(%{params: params} = conn, url) do
|
||||||
}
|
}
|
||||||
) do
|
) do
|
||||||
conn
|
conn
|
||||||
|> put_preview_response_headers()
|
|> put_preview_response_headers("image/png", "preview.png")
|
||||||
|> send_resp(200, thumbnail_binary)
|
|> send_resp(200, thumbnail_binary)
|
||||||
else
|
else
|
||||||
_ ->
|
_ ->
|
||||||
|
@ -145,10 +145,10 @@ defp handle_video_preview(conn, url) do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
defp put_preview_response_headers(conn) do
|
defp put_preview_response_headers(conn, content_type \\ "image/jpeg", filename \\ "preview.jpg") do
|
||||||
conn
|
conn
|
||||||
|> put_resp_header("content-type", "image/jpeg")
|
|> put_resp_header("content-type", content_type)
|
||||||
|> put_resp_header("content-disposition", "inline; filename=\"preview.jpg\"")
|
|> put_resp_header("content-disposition", "inline; filename=\"#{filename}\"")
|
||||||
|> put_resp_header("cache-control", "max-age=0, private, must-revalidate")
|
|> put_resp_header("cache-control", "max-age=0, private, must-revalidate")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue