Linda Kadz
Linda Kadz

Reputation: 361

Uploaded images not showing on production Heroku

I have my Phoenix LiveView App deployed to Heroku. On the app, a user can upload their profile picture and it's saved on the uploads folder. The profile picture does not render on production but shows on localhost. Is there something I'm missing?

Here's my MyAppWeb file showing the static path:

 def static_paths, do: ~w(assets fonts images uploads favicon.ico robots.txt)

Here's my MyAppWeb.Endpoint:

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

When I load the page and check the network tab, I see that the image is returning a 404, and when I click on the image, the url is:

https://myapp.heroku.com/uploads/live-view-uploads-2378293291

The path to the uploads is priv/static/uploads. Is there something I'm missing? Where am I going wrong? Any help will be appreciated. Thanks!

Upvotes: 0

Views: 34

Answers (1)

mrnovalles
mrnovalles

Reputation: 353

Unfortunately, it's not possible to upload user-generated content to the application running in Heroku. See notes about the ephemeral file system used in Heroku Dynos: https://devcenter.heroku.com/articles/dynos#ephemeral-filesystem

One solution that showed up while googling for that article is to use a simple add-on for File Uploads: https://devcenter.heroku.com/articles/simple-file-upload (not affiliated or tested by me, but seems to be common around the web)

I hope this helps!

Upvotes: 0

Related Questions