Inside a grails application, I need to upload a file under web-app/js, add a prefix, and put it in S3. I’m having trouble figuring out how to read the js file in a way that will work in development (/web-app/js) and production (/js). I’m doing this from inside a domain object.
Share
In your controllers, you can call :
and then proceed with
jsFolder.To determine the base directory of a running Grails application, use
Getting the js path from a service is a little bit tricky:
You need to implement the
ApplicationContextAwareinterface like this :However, calling this code from a domain class is not a good idea (see this thread for some explanations) and I am not even sure if it’s possible except from getting paths from manual configurations
Hope it helps.