Logotype Sitevision Developer
Log in
Log in

appResource

The AppResource utility is used to access resources within a RESTApp. Add the resources to the resource folder located in the root of the project.

js
import appResource from '@sitevision/api/server/appResource';

Methods

Resources can be accessed in three different ways, where pathToResource is the path to the file in the resource folder.

appResource.getContent(pathToResource)

Returns the resource as a UTF-8 based string.

appResource.getNode(pathToResource)

Returns the resource as a JCR Node (sv:image or sv:file).

Example

js
import router from '@sitevision/api/common/router'; import appResource from '@sitevision/api/server/appResource'; router.get('/', (req, res) => { const file = appResource.getNode('images/vacation.png'); res.sendFile(file); });
Resource folder example
Did you find the content on this page useful?