diff options
Diffstat (limited to 'lib/waev_web/controllers/exports_controller.ex')
-rw-r--r-- | lib/waev_web/controllers/exports_controller.ex | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/waev_web/controllers/exports_controller.ex b/lib/waev_web/controllers/exports_controller.ex index a3dde48..fd776a9 100644 --- a/lib/waev_web/controllers/exports_controller.ex +++ b/lib/waev_web/controllers/exports_controller.ex @@ -13,4 +13,17 @@ defmodule WaevWeb.ExportsController do |> render("404.html") end end + + def get_attachment(conn, %{"id" => id, "at_id" => at_id}) do + case Waev.Export.Message.File.path(id, at_id) do + {:ok, path} -> + send_download(conn, {:file, path}, filename: at_id) + + :error -> + conn + |> put_status(:not_found) + |> put_view(WaevWeb.ErrorView) + |> render("404.html") + end + end end |