Allow getting uploads as non-chunked

This commit is contained in:
Shadowfacts 2021-09-05 23:46:44 -04:00
parent 16c84189c3
commit a1dad5d71d
Signed by: shadowfacts
GPG Key ID: 94A5AB95422746E5
1 changed files with 21 additions and 13 deletions

View File

@ -136,11 +136,18 @@ defmodule WikiWeb.PageController do
redirect(conn, to: Routes.page_path(conn, :edit, page.id)) redirect(conn, to: Routes.page_path(conn, :edit, page.id))
end end
def get_upload(conn, _params) do def get_upload(conn, params) do
upload = conn.assigns.upload upload = conn.assigns.upload
key = get_session(conn, :content_encryption_key) key = get_session(conn, :content_encryption_key)
key = Base.decode16!(key, case: :lower) key = Base.decode16!(key, case: :lower)
if Map.get(params, "oneshot") do
data = Upload.decrypt_content(upload, key)
conn
|> put_resp_header("content-type", upload.content_type)
|> send_resp(200, data)
else
conn = conn =
conn conn
|> put_resp_header("content-type", upload.content_type) |> put_resp_header("content-type", upload.content_type)
@ -158,6 +165,7 @@ defmodule WikiWeb.PageController do
end end
end) end)
end end
end
def delete_upload(conn, _params) do def delete_upload(conn, _params) do
page = conn.assigns.page page = conn.assigns.page