Serve local cover images
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user