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
|
||||
# Extract the ID from the path
|
||||
id = List.last(conn.path_info)
|
||||
|
||||
case download_from_s3("imgs", "uploads/#{id}.png") do
|
||||
{:ok, image_binary, content_type} ->
|
||||
conn
|
||||
|> put_resp_content_type(content_type)
|
||||
|> send_resp(200, image_binary)
|
||||
|> halt()
|
||||
|
||||
{:error, reason} ->
|
||||
IO.puts(reason)
|
||||
url = "https://s3.zoeys.computer/imgs/uploads/#{id}.png"
|
||||
|
||||
conn
|
||||
|> put_resp_header("location", url)
|
||||
|> put_resp_content_type("text/plain")
|
||||
|> send_resp(500, "failed to retrieve image")
|
||||
|> send_resp(302, "Redirecting to image")
|
||||
|> halt()
|
||||
end
|
||||
else
|
||||
conn
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue