Back to all How-tos

Internal, External and Web resources

There’s a few tips in this list where I show how to reference different locations where resources can be located (such as images, snippets, JSON data). This tip clarifies exactly what those formats are and how to use them.

Internal Resources

Internal resources are accessed using a relative path, depending where they’re called from. Resources can be located in the following folders:

  • images/ contains the files in the Images folder.
  • fonts/ contains the files in the Fonts folder.
  • css/ contains the files in the StyleSheets folder.
  • js/ contains the files in the JavaScripts folder.
  • snippets/ contains the files in the Snippets folder.

When refering to them, normally you would simply use the path directly with the file name. The structure within those folders is maintained, so if you create a “signatures” folder within the “Images” folder, you need to use it. For example, <img src="images/signatures/johnsmith.gif">. In Scripts, you can refer to them in the same way: results.loadhtml("snippets/en/navbar.html"); for example.

One little detail: When refering to images or fonts from a CSS file, you need to remember that the current path is css/, meaning you can’t just call images/image.jpg. For example: #header { background-image: url('../images/image.jpg'); }

External Resources

External resources are accessed using a path either on the hard drive or on a network drive. The path must be used with forward slashes, with the file:///prefix. For example, <img src="file:///c:/resources/images/signatures/johnsmith.gif"> or var json_variables = loadjson("file:///d:/jsondata/variables.json");

Network paths are similar, however they only have 2 slashes and not 3: results.loadhtml("file://servername/sharename/folder/snippet.html");

Some limitations:

  • Stylesheet cannot refer to external resources. They are not “processed” in this way.
  • The Connect Server user needs access to whichever network path is used. If the network path is on a domain, the Connect Server must be identified with domain credentials that have access to the domain resources.

For more information on Network Paths, please see this Wikipedia Entry.

Web Resources

Web resources are simple accessed using a full URL. This URL needs to be publicly accessible, meaning if you type in that URL in a browser on the server, it needs to be visible. Authentication is possible only through URL Parameters (http://www.example.com/data.json?user=username&password=password) or through HTTP Basic Auth (http://username:password@www.example.com/data.json).

If a resource is called form a Workflow instance, it can be accessed through 2 ways:

  • “Static Resources”, as set in the Preferences, are accessed using the resource path, by default something like http://servername:8080/_iRes/images/image.jpg.
  • Resources can also be served by processes: http://servername:8080/my_process?filename=image.jpg (assuming “my_process” is the action in the HTTP Server Input).

Leave a Reply

Your email address will not be published. Required fields are marked *