I'm developing a CMS and I'd like users to be able to upload their own images, CSS files and the like. For the safety of the resources, I do not want to store the uploaded files within the application structure / deployed WAR.
What is the easiest way to serve content in grails, from a controller from a non-grails location?
After much research and questioning, I decided to package the static resources (such as images) in the database. The advantages of this are:
The disadvantages are:
I decided to go with the solution, even though there are these disadvantages. This is how I dealt with them:
I'm using Smart Browser Caching by making use of etags (documentation) and using EHCache (documentation) to cache the images server side. As soon as a new image is uploaded, the e-tag is changed, and the cache is cleared, forcing the browser to download a fresh copy.
So far, the loss of performance from the MySQL database has been un-noticable, and performance is lightning fast.