Serve local cover images

This commit is contained in:
Claudio Ortolina
2024-09-16 09:50:07 +01:00
parent f1160eddd4
commit afc1802399
12 changed files with 92 additions and 15 deletions
@@ -0,0 +1,17 @@
defmodule MusicLibraryWeb.ImageController do
use MusicLibraryWeb, :controller
alias MusicLibrary.Records
def show(conn, %{"record_id" => record_id}) do
{:ok, image_data} = Records.get_image!(record_id)
if image_data do
conn
|> put_resp_content_type("image/jpeg", "utf-8")
|> send_resp(200, image_data)
else
conn |> send_resp(404, "Not found")
end
end
end