Where to put temporary files when deploying?

Thank you @LostKobrakai.

For future readers: you’d use System.tmp_dir/0 for the path. So if you want to write a content.png, it would go to

File.write!(
  System.tmp_dir() <> "/content.png",
  your_content_here
)

You can tell Phoenix to serve these as static files by adding a plug in MyAppWeb.Endpoint immediately after the only Plug.Static:

plug Plug.Static,
  at: "/",
  from: :my_app,
  gzip: false,
  only: MyAppWeb.static_paths()

# 👇 ADD THIS
plug Plug.Static,
  at: System.tmp_dir(),
  from: System.tmp_dir()