I have a Grails app. I want to move out all the images users upload to a directory outside of my web-app directory, somewhere else on the disk. Then I want to allow my application to serve them on pages but users can't access the directory. I know one way if to use an ImageController that reads the image and streams it to the view, but that has some trades-off such as caching. I was wondering if there is a way to allow apache to serve images from a local directory outside the web-app and restrict it to the app only.

  • Yes it is possible. I'll come back to this question in a couple of days and answer for real if it hasn't gotten an answer by then (I can only do casual answers for the moment and this needs some proper attention). – ErikE Dec 25 '13 at 8:21

I tried this, and it worked. But It also allows the client to access it since it only maps it. But again I appreciate if anyone can elaborate more and offer another solution that provides more control over how web app and users can access this area.

basically added this in Tomcat /conf/server.xml inside <Host> tag:

<Context docBase="/path/to/images" path="/images" />

Found out that someone answered something like what I needed here : Simplest way to serve static data

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.