How to send the file with password with bitwarden-cli

Hello,

I’m trying to send file with password by bitwarden-cli.

What I tried.

> bw send template send.file | jq ".name=\"My First Send\" |.file.fileName=\"0497.txt\" | .password=\"mypassword\" | .deletionDate=\"2021-03-24T06:50:53.462Z\"" | bw encode | bw send create
Must specify text content to Send either with the --text option or in the encoded json

so, I put “–text” option to “bw send create” command,

bw send template send.file | jq ".name=\"My First Send\" |.file.fileName=\"0497.txt\" | .password=\"mypassword\" | .deletionDate=\"2021-03-24T06:50:53.462Z\"" | bw encode | bw send create --text sample_text
Send created! It can be accessed at:
https://send.bitwarden.com/#******************/****************

It looks I can send the file, but I can send the text , not the file.

Please tell me how to send the file with password with bitwarden-cli.

Thanks.

Hmmm… Do you have a premium account? It’s required to send file attachments, just in case we need to start there :slight_smile:

@tgreer

Thanks for your reply.
Yes, I have premium account, and sending a file without password from cli, works well.

> bw send -f 0497.txt
Send created! It can be accessed at:
https://send.bitwarden.com/#****************/**************

Hello, I could manage to send the file with password by bitwarden-cli, but I’m not sure this is a correct way,

> bw send template send.file | jq ".name=\"My First Send\" | .type=1 | .file.fileName=\"0497.txt\" |  .password=\"mypassword\" | .deletionDate=\"2021-03-24T06:50:53.462Z\""  | bw encode | bw send create
Send created! It can be accessed at:
https://send.bitwarden.com/#*******************/**********

The reason why I couldn’t send the file was “.type” in JSON file.
bw send template send.file command generate following JSON file.

>bw send template send.file  | jq .
{
  "object": "send",
  "name": "Send name",
  "notes": "Some notes about this send.",
  "type": 0,
  "text": null,
  "file": {
    "fileName": "file attachment location"
  },
  "maxAccessCount": null,
  "deletionDate": "2021-03-24T14:30:47.393Z",
  "expirationDate": null,
  "password": null,
  "disabled": false
}

“type”: 0 is for sending text.
“type”: 1 is for sending file.

Is the JSON file generated by bw send template send.file expected one?
(If the JSON file is a template for sending file, I think, 1 is better for type’s value.)