You can upload files to the Blackfynn platform programmatically using the Blackfynn Command Line Interface (CLI). Below are instructions to: 

  1. install the CLI
  2. setup a profile for your account
  3. upload data using the CLI

Installation

In order to use the CLI, you must install the Python Client. This will also install the CLI. In addition, you need to create an API token & secret in the web application.

Create connection profile

After installing the Python client, you can use the CLI. The first step is to create a profile that allows the CLI to access the platform on your behalf.  To create a profile, run bf profile create from the command line:

bf profile create

You then be taken through the steps to name your profile. Give your profile a unique name, and enter the API token and secret.

$ bf profile create

Blackfynn profile setup assistant
Create a profile:
  Profile name [default]:
Creating profile 'default'
  API token: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
  API secret: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Would you like to set 'default' as default (Y/n)? y
Default profile: default

To verify that your profile was set up correctly, run bf env

$ bf status

Active profile:
  default

Blackfynn environment:
  User          : <your email>
  Organization  : <your organization>
  API Location  : https://api.blackfynn.io
  Streaming API : https://streaming.blackfynn.io

Uploading data using the CLI

Once you have created a profile associated with your Blackfynn account, you can upload data to a specific dataset. To select which dataset you want to upload data to, use the bf datasets  command to receive a list of all available datasets that you can access.

$ bf datasets

  dataset_1 (id: N:dataset:98a1fc-9346-49cc-bdf1-52c11faa060)
  dataset_2 (id: N:dataset:66a239a-945c-4d32-ad2d-dcba09c81da)
  my_dataset (id: N:dataset:d03785-07e8-4df4-8b63-3d0794c60fc)
  shared_dataset (id: N:dataset:cb4fae-6dd7-430c-82fc-f07bcc20d49)

Then set which dataset you want to upload to using the bf use  command. You can use the dataset name, or the dataset id as the argument of the method:

$ bf use N:dataset:98a1fc-9346-49cc-bdf1-52c11faa060

or

$ bf use dataset_1

Finally use the bf upload  command to upload the data. This can point to a file or a folder on your computer

$ bf upload /path/to/my_data

if you want to upload data to a specific collection/folder inside the dataset, you can specify this with the --to parameter. You can find the collection-id in the url for web application when you navigate into the specific folder in the files browser. For example:

$ bf upload --to=N:collection:d4cb103e-7765-4...  ~/Desktop/data/

For more information about  bf upload  command, you can use the help command.

$ bf upload --help


NOTE: Visit the Developers Documentation for additional information about the functionality of the CLI.

Did this answer your question?