Using foldershare php client

Terminal

A. FolderShare command line client

FolderShare supports REST web services for command-line access. You can use this to upload, download, and change files and folders from a terminal window or script on a Mac, Windows, or Linux desktop, laptop, or supercomputer.

  1. Complete the php setup as described in previous step
  2. Download and unzip the foldershare php client (requires PHP 7.2+)
  3. #fetch foldershare php client from project website
    curl -OL http://seedmelab.org/sites/default/files/downloads/foldershare_php_client.1.0.zip
    unzip foldershare_php_client.1.0.zip
    cd foldershare_php_client.1.0
    
  4. Type "./foldershare --help" in a terminal window to get help.  You must have php in your path or type "/full/path/to/php ./foldershare --help"

B. Command set

You will need this temporary site's host name and your user name and password in order to connect to this site. For instance, you can list top level folders like this:

./foldershare --host hostname --username login --password password  ls /

Many Linux-style file and folder commands are supported, such as:

  • "ls" to list a folder's contents.
  • "stat" to get the status of a file or folder.
  • "mkdir" to make a new folder.
  • "rm" to remove a file or folder tree.
  • "rmdir" to remove an empty folder.
  • "cp" to copy a file or folder.
  • "mv" to move a file or folder.

There are a few more commands particular to web services, such as:

  • "download" to download a file or folder.
  • "upload" to upload a file or folder.
  • "update" to change a file or folder's description.

C. FolderShare shell for interactive usage

Login to the site, this will drop the user in a foldershare shell, which enables easier manual interaction

./foldershare --host hostname --username login --password password 

Create a new folder say "myfolder" at the top level, visible under Personal files through the web browser

foldershare> mkdir --help
foldershare> mkdir /myfolder

Upload a local file to the site using the upload command 

foldershare> upload --help
foldershare> upload /full/localpath/omega.zip /myfolder

Add a description to a file using the update command

foldershare> update --help
foldershare> update description 'this is metadata' /myfolder/omega.zip

Download a folder using the download command, this will zip and download the contents if appropriate

foldershare> download --help
foldershare> get /myfolder /full/localpath

D. Scripted usage example

Create a variable to hold the following information

prefix="./foldershare --host hostname --username login --password password"

Create a new folder say "myfolder" at the top level, visible under Personal files through the web browser

$prefix mkdir /myfolder

Upload a local file to the site using the upload command 

$prefix upload /full/localpath/omega.zip /myfolder

Add a description to a file using the update command

$prefix update description 'this is metadata' /myfolder/omega.zip

Download a folder using the download command, this will zip and download the contents if appropriate

$prefix download /myfolder /full/localpath