Local Liveview Uploads in production

In the context of the local dev environment this works great, since the application is running from the project’s root folder. In prod, however, your application is running from within _build/prod/rel/..., thus why the file isn’t copied where you intended to when you pass a relative path.

Now, the uploads directory is pretty much a config concern, meaning I would personally prefer to have it in a config file rather than in a module’s function or a module’s attribute. For prod, pass the absolute path to it.

Example:

# dev.exs
config :labs, upload_path: "priv/static/uploads"
# prod.exs
config :labs, upload_path: "/var/www/labs/priv/static/uploads"

Retrieve it with Application.fetch_env!(:labs, :upload_path)