Introducing The Filestack Command-Line Interface

Command-line Interface

Filestack provides a robust and scalable solution for content upload and file delivery. We are used for websites, digital services, enterprise software and endless other projects across the industry. Our File Picker is easily integrated into any website, and we have a growing list of SDKs for use in projects of various languages, including plugins for popular frameworks.

Sometimes, though, it’s useful to quickly upload files in your local development environment, without additional scripts. That’s why we are happy to announce the release of our Filestack CLI (command-line interface). Now it’s as simple as running a single shell command to upload files using Filestack.

Set Up

There are two ways to setup the Filestack CLI. You can run the initialization command

$ fs-cli init

and follow the instructions by entering your API key, as well as your management credentials (optional, but necessary if you want to get a list of your apps or create a new one). This creates a config file at ~/.fsrc with your environment information.

Or you can do this yourself by creating a file at ~/.fsrc in the following format:

[default]
APIKEY=YOUR_API_KEY
# optional
CLIENT_ID=YOUR_CLIENT_ID 
CLIENT_SECRET=YOUR_CLIENT_SECRET

[another_environment]
APIKEY=YOUR_OTHER_API_KEY

Environments

Many of our customers have more than one application, and thus more than one API key. The Filestack CLI allows you to add additional environments and pass them to any command for use:

$ fs-cli -e ENVIRONMENT_NAME [COMMANDS]

This can be done for any command. If no environment is specified, the default environment will be used.

Uploading with Command-Line Interface

Upload a file using the following command:

$ fs-cli upload path/to/file

You can also upload an entire directory of files, although this is not recursive (sub-directories will not be uploaded or searched):

$ fs-cli upload path/to/directory

It’s fine to mix files and directories:

$ fs-cli upload path/to/file path/to/directory

Each file that is uploaded will return back a new filehandle to the terminal.

Application Management

There are currently two management functions available in the Filestack CLI: application listing and application creation.

List applications will return a prettified JSON string back to the terminal detailing your apps and all of their info:

$ fs-cli manage list_apps

And if you need to create a new application, that’s easy, too:

$ fs-cli manage create_app --url http://yoururlhere.com --name application_name --save-to-env name_of_new_environment

The –save-to-env option allows you to save the API key of your newly created application to your ~/.fsrc file for immediate use.

Read More →