How to Download a Static File from Phoenix

From ElixirBlocks
Jump to: navigation, search
defmodule AppWeb.PageController do
  use AppWeb, :controller
  def home(conn, _params) do

    path = Application.app_dir(:app, "priv/test.json") #static directory
    send_download(conn, {:file, path})
    render(conn, :home, layout: false)
  end
end