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:
The
template
command (template) to output the appropriate JSON template for your Share type.A command-line JSON processor such as jq to manipulate the template output as required.
The
encod
e command (encode) to encode the manipulated JSON.The
create
command to create a Share from the encoded JSON.
Examples
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
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
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.
Option | Description |
---|---|
| Specify the file to Share (this can also be specified in encoded JSON). |
| Specify the text to Share (this can also be specified in encoded JSON). |
| Specify that a text Share require recipients to toggle visibility. |
| Specify the password needed to access password-protected. |
| Output the full Share object as JSON rather than only the Share link (pair this option with the |
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