redirect instead

This commit is contained in:
zack 2024-10-25 19:59:30 -04:00
parent d08bb72dca
commit 76ac2d568a
No known key found for this signature in database
GPG key ID: 5F873416BCF59F35

View file

@ -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