jerry
1
Hello Team,
Can someone assist me, please?
I have images stored in /usr/local/uploads/
How do I server these images through a route?
E.g.
I want to serve the image, jerry.jpg, which is located under /user/local/uploads/
Thanks in advance.
Jerry
idi527
2
Try using Plug.Static
.
If you are using a phoenix project, you can add or modify the plug Plug.Static ...
block in your endpoint.ex
.
2 Likes
jerry
3
I am not using Phoenix.
I am using Elixir with Plugs.
Do you have a sample script to guide me, please?
Thanks in advance.
idi527
4
I am not using Phoenix.
I am using Elixir with Plugs.
Then it’s even easier. Just add a plug somewhere in your plug pipeline.
Do you have a sample script to guide me, please?
defmodule MyApp.Router do
use Plug.Router # or Plug.Builder
# ...
plug(Plug.Static, at: "/images", from: "/usr/local/uploads")
# ...
end
There’s more information on hexdocs.
1 Like
jerry
5
Thanks so much.
I will feedback on the outcome.
Regards,
Jerry
1 Like