forked from AkkomaGang/akkoma
[#2497] Added Cache-Control response header for media proxy preview endpoint.
This commit is contained in:
parent
3737f38432
commit
0a839d51a7
1 changed files with 10 additions and 6 deletions
|
@ -107,8 +107,7 @@ defp handle_png_preview(%{params: params} = conn, url) do
|
||||||
}
|
}
|
||||||
) do
|
) do
|
||||||
conn
|
conn
|
||||||
|> put_resp_header("content-type", "image/png")
|
|> put_preview_response_headers()
|
||||||
|> put_resp_header("content-disposition", "inline; filename=\"preview.png\"")
|
|
||||||
|> send_resp(200, thumbnail_binary)
|
|> send_resp(200, thumbnail_binary)
|
||||||
else
|
else
|
||||||
_ ->
|
_ ->
|
||||||
|
@ -126,8 +125,7 @@ defp handle_jpeg_preview(%{params: params} = conn, url) do
|
||||||
%{max_width: thumbnail_max_width, max_height: thumbnail_max_height, quality: quality}
|
%{max_width: thumbnail_max_width, max_height: thumbnail_max_height, quality: quality}
|
||||||
) do
|
) do
|
||||||
conn
|
conn
|
||||||
|> put_resp_header("content-type", "image/jpeg")
|
|> put_preview_response_headers()
|
||||||
|> put_resp_header("content-disposition", "inline; filename=\"preview.jpg\"")
|
|
||||||
|> send_resp(200, thumbnail_binary)
|
|> send_resp(200, thumbnail_binary)
|
||||||
else
|
else
|
||||||
_ ->
|
_ ->
|
||||||
|
@ -139,8 +137,7 @@ defp handle_video_preview(conn, url) do
|
||||||
with {:ok, thumbnail_binary} <-
|
with {:ok, thumbnail_binary} <-
|
||||||
MediaHelper.video_framegrab(url) do
|
MediaHelper.video_framegrab(url) do
|
||||||
conn
|
conn
|
||||||
|> put_resp_header("content-type", "image/jpeg")
|
|> put_preview_response_headers()
|
||||||
|> put_resp_header("content-disposition", "inline; filename=\"preview.jpg\"")
|
|
||||||
|> send_resp(200, thumbnail_binary)
|
|> send_resp(200, thumbnail_binary)
|
||||||
else
|
else
|
||||||
_ ->
|
_ ->
|
||||||
|
@ -148,6 +145,13 @@ defp handle_video_preview(conn, url) do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defp put_preview_response_headers(conn) do
|
||||||
|
conn
|
||||||
|
|> put_resp_header("content-type", "image/jpeg")
|
||||||
|
|> put_resp_header("content-disposition", "inline; filename=\"preview.jpg\"")
|
||||||
|
|> put_resp_header("cache-control", "max-age=0, private, must-revalidate")
|
||||||
|
end
|
||||||
|
|
||||||
defp thumbnail_max_dimensions(params) do
|
defp thumbnail_max_dimensions(params) do
|
||||||
config = Config.get([:media_preview_proxy], [])
|
config = Config.get([:media_preview_proxy], [])
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue