"Phoenix.Router.NoRouteError" when attempting to access uploaded image file in sub directory of Phoenix application

221 Views Asked by At

Phoenix/Elixir learner here :)

I tried to access an image file under sub directory (ie:dashboard) of a Phoenix application, something like :

http://localhost:8000/dashboard/media/tv1_1.jpg

but it keeps throwing me with the same error messages

Phoenix.Router.NoRouteError at GET /dashboard/media/tv1_1.jpg
no route found for GET /dashboard/media/tv1_1.jpg

Here is a snippet of my configuration setting in endpoint.ex

  plug Plug.Static,
    at: "/dashboard",
    from: :my_dashboard,
    gzip: false,
    only: ~w(css fonts images js favicon.ico robots.txt)

  plug Plug.Static, at: "/media",
  from: "user_media",
  only: ~w(*.mp4 *.jpg *.jpeg *.png)

Also, I put upload folder (user_media) on the same level of Phoenix application's root directory.

Hope someone could pinpoint of what I've missed here.

Thanks in advance.
-dewa-

0

There are 0 best solutions below