Module resource - how to obtain absolute folder path

I try to obtain absolute file path of a config resource but it seems not possible ?

I’m probably missing something, or maybe it’s intentional, but the API only exposes logical data and hides the actual file system hierarchy.

When I create or find the resource, from the resource object, I can't obtain the absolute folder path.

ResourceType type = new ResourceType(Constantes.MODULE_ID,"license");
Optional<Resource> resourceFind = context.getConfigurationManager().getConfigCollection().getSingletonResource(type);
...
resourceFind.get()

My Resource contain a file and I need to pass the absolute folder of this file when calling an external library.

Mostly intentional/you ideally shouldn't need to resolve exact file paths. There's a static utility method, but it's considered implementation rather than API so not easily accessible to you.

Technically the correct logic would be to check com.inductiveautomation.ignition.common.SystemProps#CONFIG_DIRECTORY; if it's not present then you resolve:

context
        .getSystemManager()
        .getDataDir()
        .toPath()
        .resolve("config/resources")
        .toAbsolutePath()

Then resolving an explicit resource under that relies on reversing the resource type / folder path encoding scheme.

A safer/saner approach might be to copy the data you need into a module-specific temp directory and point the external lib there.

Thanks a lot, that make sense.

Using Config Resources was convenient for me to store data synchronized between master/backup gateway...

{
  "scope": "A",
  "version": 1,
  "restricted": false,
  "overridable": true,
  "files": [
    "verification.txt",
    "config.json"
  ],
  "attributes": {}
}