Skip to main content

create

Use the create command to create a Share; it allows more advanced configuration than using only bsafe share and takes encoded JSON for its argument:

bsafe share create [options] <encodedJson>

In a typical workflow you could use:

  1. The template command (template) to output the appropriate JSON template for your Share type.

  2. A command-line JSON processor such as jq to manipulate the template output as required.

  3. The encode command (encode) to encode the manipulated JSON.

  4. The create command to create a Share from the encoded JSON.

Examples

  1. To create a text Share:

    bsafe share template share.text | jq '.name="My Share with you" | .text.text="What I want to share."' | bsafe encode | bsafe share create
  2. To create a password-protected file Share:

    bsafe share template share.file | jq '.name="My File Share for you" | .type=1 | .file.fileName="paperwork.png" | .password="myp@ss0"' | bsafe encode | bsafe share create
  3. To create a password-protected file Share with an explicit deletion date (depending on how .deletionDate= should be specified on your operating system:

    • Windows

      $delDate = (Get-Date).AddDays(14) | date -UFormat "%Y-%m-%dT%H:%M:%SZ" bsafe share template share.text | jq ".name=\`"My Share with you\`" | .text.text=\`"What I want to share.\`" | .password=\`"password\`" | .deletionDate=\`"$delDate\`"" | bsafe encode | bsafe share create
    • macOS

      bsafe share template share.text | jq ".name=\"My Share with you\" | .text.text=\"What I want to share.\" | .password=\"mypassword\" | .deletionDate=\"$(date -uv+14d +"%Y-%m-%dT%H:%M:%SZ")\"" | bsafe encode | bsafe share create
    • Linux

      bsafe share template share.text | jq ".name=\"My Share with you\" | .text.text=\"What I want to share.\" | .password=\"mypassword\" | .deletionDate=\"$(date "+%Y-%m-%dT%H:%M:%SZ" -d "+14 days")\"" | bsafe encode | bsafe share create

    In these examples the jq invocation must be wrapped in double quotes (" ") and use escapes (\) for each filter due to a nested date variable that configures a .deletionDate in the Share.

Table 1. create subcommand options

Option

Description

--file <path>

Specify the file to Share (this can also be specified in encoded JSON).

--text <text>

Specify the text to Share (this can also be specified in encoded JSON).

--hidden

Specify that a text Share require recipients to toggle visibility.

--password <password>

Specify the password needed to access password-protected.

--fullObject

Output the full Share object as JSON rather than only the Share link (pair this option with the --pretty option for formatted JSON).



Use the template command to return the expected JSON formatting for a Share object; it takes an <object> specification, either share.text or share.file, for its argument.

bsafe share template <object>

Typically, you would use this command to pipe the output into a bsafe share create operation, using a command-line JSON processor like jq and bsafe encode to manipulate the values retrieved from the template, for example:

bsafe share template share.text | jq '.name="My Share for you" | .text.text="What I want to share."' | bsafe encode | bsafe share create

The encode command Base 64 encodes stdin. This command is typically used in combination with a command-line JSON processor such as jq when performing create and edit operations, for example:

bsafe get template folder | jq '.name="My First Folder"' | bsafe encode | bsafe create folder
bsafe get item 7ac9cae8-5067-4faf-b6ab-acfd00e2c328 | jq '.login.password="newp@ssw0rd"' | bsafe encode | bsafe edit item 7ac9cae8-5067-4faf-b6ab-acfd00e2c328