A lasting URL of your app for a file that is not public: it checks that
the person may see the file, then redirects to a URL the store signs
for a few minutes (Storehouse.signed_url/2). Keep this URL in your
records and documents, not the signed one, which expires.
In the router, in a scope that has the person (:fetch_session, your
authentication):
forward "/files", Storehouse.Redirect, authorize: &MyAppWeb.Files.allowed?/2/files/2026/10/0b6…-board.png then redirects to the file. The
function takes the conn and the key; a key it refuses, or that is not a
valid key, gives 404, so that no one learns which files exist.
defmodule MyAppWeb.Files do
def allowed?(conn, key), do: MyApp.Files.visible?(conn.assigns.current_scope, key)
endOptions
:authorize- the function (required).truelets everyone in: for a store whose files are private only so that their URLs expire.:expires_in- how long the signed URL is valid, in seconds. The default is 300.:disposition-"inline"or"attachment", for the signed URL. A request's?download=1asks for a download.:adapter- the store. The default isStorehouse.adapter/0.