I'm trying to figure out a pattern for uploading and serving files (images) locally. I figured out the upload part, but a little confused on the storage and serve part.
I'm confused about how to display locally stored images on a single page using "Ok.sendFile". How do tie it into "img src" tags on the view? The other option I could think of is to run a (separate) web server locally just for storing files, which doesn't make much sense.
Just add an Action in a Controller that provides the image:
Then add the corresponding route in your
routes
file:And your HTML should look like:
or if you use the Scala templates: