File system drivers are normally bundled with scopes drivers (see Scopes Drivers). Normally, before a file system driver is accessed, the user should authenticate the corresponding scope (e.g., the "https://www.googleapis.com/auth/drive" scope in the "google_scopes" driver).
After the scope is authenticated and the correspoding credentials stored (in the registry or in some other place), the corresponding remote file system can be mounted. After mounting, a virtual subdirectory within webAppOS user's home directory will be available (we call this directory a mount point).
To mount a remote file system:
create the registry key "users/[login]/fs_mount_points/[path/to/mount/point]" with the value equal to the remote location string. The location string must start with the driver-specific prefix, e.g., "onedrive:" or "gdrive:", followed by the driver-specific remote location.
The mount point path is relative to the user's home directory. To mount a remote file system for all users, use the special value "all users" for the [login] part of the registry key. The driver should be able to find the corresponding credentials.
create the subdirectory corresponding to the mount point within the user's home directory.
The prefix will be used by webAppOS Home File System to determine the driver implementation. Normally, the driver should implement server-side File System API. However, to support serverless webAppOS applications, the file system driver can also provide a client-side implementation of File System API.
The driver should check on a regular basis (e.g., once a minute) the registry keys mentioned above as well as the credentials used to connect to the remote file system. In case the registry key is not present or credentials have changed, the driver must consider that the mount point has been unmounted. For some drivers, however, this check may be irrelevant.
The server-side implementation must implement the org.webappos.fs.IFileSystem Java interface (see webAppOS File System API) and specify the corresponding implementation class in webservice.properties:
fs_driver=some.java.package.JavaClassImplementingIFileSystem
# extends org.webappos.fs.IFileSystem;
fs_prefix="gdrive:"
# some prefix that will be used by webAppOS Home File System
# to determine the file system driver, which will serve the corresponding mount point
The class constructor must take on string: the location of the remote file system. User's credentials (access tokens) must be taken from the registry (or where the corresponding scopes driver saved them). The location string can contain additional options, e.g., the account name to use or the "readonly" flag. These options are driver-specific, and the corresponding driver documentation must be consulted.
The client-side implementation (for serverless access) must be accessible via services/[scopes_driver_name]/[fs_prefix]_fs_driver.js
The [fs_prefix]_fs_driver.js must define an asynchronous (AMD) module that returns a JavaScript constructor function implementing webAppOS File System API.
The constructor function must take two arguments: the location of the remote file system and the options. It must return a JavaScript object implementing methods from org.webappos.fs.IFileSystem (however, the downloadFile function must return a URL string instead of java.io.InputStream).
define(function(){
var ...; // private properties
return function(location, options) {
this.copyPath = async function(src, dst) {
...
};
this.createDirectory = async function(path) {
...
};
... // other functions from IFileSystem implemented in JavaScript,
// however, the downloadFile function must return a URL string
// instead of java.io.InputStream
return this;
};
})