data create file
Upload a local file to an org.
This command always creates a new file in the org; you can’t update an existing file. After a successful upload, the command displays the ID of the new ContentDocument record which represents the uploaded file.
By default, the uploaded file isn’t attached to a record; in the Salesforce UI the file shows up in the Files tab. You can optionally attach the file to an existing record, such as an account, as long as you know its record ID.
You can also give the file a new name after it’s been uploaded; by default its name in the org is the same as the local file name.
| Flag Name (Long) | Flag Name (Short) | Description |
|---|---|---|
‑‑api‑version | N/A | Type: Value Override the api version used for api requests made by this command |
‑‑file | ‑f | Type: Value Required Path of file to upload. |
‑‑flags‑dir | N/A | Type: Value Import flag values from a directory. |
‑‑json | N/A | Type: Boolean Format output as json. |
‑‑parent‑id | ‑i | Type: Value ID of the record to attach the file to. |
‑‑target‑org | ‑o | Type: Value Required Username or alias of the target org. Not required if the target-org configuration variable is already set. |
‑‑title | ‑t | Type: Value New title given to the file (ContentDocument) after it’s uploaded. |
Upload the local file “resources/astro.png” to your default org:
Give the file a different filename after it’s uploaded to the org with alias “my-scratch”:
Attach the file to a record in the org: