FolderShare REST Logo
This module provides REST web services for the FolderShare module. This enables users to use non-browser client applications to upload, download, create, delete, and modify shared files and folders managed by FolderShare.

Uses

While a web browser provides interactive access to a web site, REST web services enable automatic scripted access as well as alternate client applications that may present customized user interfaces. For instance, the included command-line REST client provides a shell-like interface and Linux/BSD/macOS-style commands to access shared files (e.g. "ls", "cp", "rm"). This command-line client can be used interactively, or embedded in shell scripts that compute or process data and automatically post results to a web site.


Demo

View sample command line interaction

Requirements

  1. Drupal 10.2.x
  2. PHP 8.2.x
  3. FolderShare module

FolderShare REST client

The "client" subdirectory in this module contains a PHP command-line client named "foldershare" that uses REST connections to access FolderShare files. This script may be distributed to a site's users.


FolderShare REST client requirements

The client requires:

  • A recent version of PHP available on the user's host.
  • A site REST configuration with JSON or JSON+HAL serialization enabled. XML serialization is not supported.
  • A site with standard cookie-based authentication.

FolderShare REST client usage

From a terminal window, help is available:

./foldershare --help
To connect to a site, the site's name must be given using the "--host" option. Login credentials may be given using "--username" and "--password" options. The rest of the command line provides a REST command to execute, such as "ls".

./foldershare --host MYHOST --username MYNAME --password MYPASSWORD ls
If a user name is provided, but no password, the user will be prompted for the password. If a user name is not provided, the user will access the site anonymously, just as they would by using a web browser without logging into the site.

If no REST command is given, the script will enter an interactive mode that prompts for commands.

./foldershare --host MYHOST

Many Linux/BSD/macOS-style commands are supported, such as:

  • 'cp' to copy a file or folder.
  • 'hostname' to get the name of the remote host.
  • 'ls' to list a folder's contents.
  • 'mkdir' to create an empty folder.
  • 'mv' to move or rename a file or folder.
  • 'rm' to remove a file or folder.
  • 'rmdir' to remove an empty folder.
  • 'stat' to get file or folder attributes.
  • 'whoami' to get the user's name.
  • 'xattr' to get extended file attributes.

Many Linux/BSD/macOS-style command options are also supported. For instance, "ls -l" gives a long folder listing and "rm -r" deletes a folder tree recursively. To get help on a command, add the "--help" option (e.g. "ls --help").

Several custom commands are supported, such as:

'download' to download files and folders.
'update' to change attributes of a file or folder.
'upload' to upload files and folders.

Acknowledgements

Supporting organizations: 
Conceived and developed the module

Project information

Releases