diff options
author | Guillermo Ramos | 2020-02-05 14:17:41 +0100 |
---|---|---|
committer | Guillermo Ramos | 2020-02-05 14:17:41 +0100 |
commit | a0eec8eadae94a71974868ac8d48820e0662857b (patch) | |
tree | f85dad657a8f7bea59fbb96e39a7e506986b8ed5 /lib/waev_web/controllers/exports_controller.ex | |
parent | 01143da6e79f26cfacefa0c17f225ccc88d15186 (diff) | |
download | waev-a0eec8eadae94a71974868ac8d48820e0662857b.tar.gz |
Download attachments
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 |