shaydel
shaydel

Reputation: 589

Grails : getting assets local storage path inside the controller

I need to extract the assets folder physical path in order to write a file from my controller.

Any short way of achieving the file persistency from the controller?

Upvotes: 3

Views: 2157

Answers (2)

Eduardo Cuomo
Eduardo Cuomo

Reputation: 18986

Complete example:

class ExampleService {
  def assetResourceLocator

  def someMethod() {
    Resource res = assetResourceLocator.findAssetForURI('test.css')
    String url = res.getURL()
    String uri = res.getURI()
  }
}

Source: https://stackoverflow.com/a/39642278/717267

Upvotes: 2

Biswas
Biswas

Reputation: 598

Look at the AssetProcessorService inside the plugin. There are different function to get the path like getAssetPath or getResolvedAssetPath. This might help you.

Upvotes: 0

Related Questions