redirect instead
This commit is contained in:
parent
d08bb72dca
commit
76ac2d568a
1 changed files with 6 additions and 15 deletions
|
|
@ -147,22 +147,13 @@ defmodule ZoeyscomputerWeb.Router do
|
||||||
if is_discord do
|
if is_discord do
|
||||||
# Extract the ID from the path
|
# Extract the ID from the path
|
||||||
id = List.last(conn.path_info)
|
id = List.last(conn.path_info)
|
||||||
|
url = "https://s3.zoeys.computer/imgs/uploads/#{id}.png"
|
||||||
|
|
||||||
case download_from_s3("imgs", "uploads/#{id}.png") do
|
conn
|
||||||
{:ok, image_binary, content_type} ->
|
|> put_resp_header("location", url)
|
||||||
conn
|
|> put_resp_content_type("text/plain")
|
||||||
|> put_resp_content_type(content_type)
|
|> send_resp(302, "Redirecting to image")
|
||||||
|> send_resp(200, image_binary)
|
|> halt()
|
||||||
|> halt()
|
|
||||||
|
|
||||||
{:error, reason} ->
|
|
||||||
IO.puts(reason)
|
|
||||||
|
|
||||||
conn
|
|
||||||
|> put_resp_content_type("text/plain")
|
|
||||||
|> send_resp(500, "failed to retrieve image")
|
|
||||||
|> halt()
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
conn
|
conn
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue