Accessing Filesystem Resources (org.apache.sling.fsresource)
The Filesystem Resource Provider provides access to the operating system's filesystem through the Sling
ResourceResolver. Multiple locations may be mapped into the resource tree by configuring the filesystem location and the resource tree root path for each location to be mapped.
To activate this feature, install the
org.apache.sling.fsresource bundle. You can get it from the Sling downloads page or build it yourself from the source code
found under bundles/extensions/fsresource.
Files and directories are mapped into the resource tree as regular
Resource instances whose resource type depends on the actual nature of the mapped filesystem resource:
- Regular files are assigned the
- Directories are assigned the
Filesystem resources extend from Sling's
AbstractResource class and thus are adaptable to any type for which an
AdapterFactory is registered supporting file system resources. In addition Filesystem Resources support the following adapters natively:
java.io.File-- The Java file object providing access to the filesystem file
java.net.URL-- A valid
file://URL to the file. This URL is derived from the
java.io.Fileobject by calling the
java.io.InputStream-- If the
java.io.Filecan be read from (as per
InputStreamto read from the file is returned.
The Filesystem Resource Provider is configured with OSGi Configuration Admin factory configurtions whose factory PID is
org.apache.sling.fsprovider.internal.FsResourceProvider. Configuration can be managed using the OSGi Configuration Admin API, through the Web Console or by any other means supporting Configuration Admin configurations.
The following configuration properties must be specified:
||Location in the virtual resource tree where the filesystem resources are mapped in. This property must not be an empty string.|
||Filesystem directory mapped to the virtual resource tree. This property must not be an empty string. If the path is relative it is resolved against