Upload a File to Your Org
Use the data create file CLI command to upload a
local file to your org. The file is uploaded to the ContentDocument standard object; when the
command finishes it outputs the new record ID. In the Salesforce UI, the uploaded file is
available from the Files tab. The command always creates a new file in the org; you can’t update
an existing file. If you create a file with the name of an existing file, a new duplicate record
is created.
This simple example shows how to upload the file called astro.png to an org with the alias new-scratch-org:
1sf data create file --file astro.png --target-org new-scratch-orgBy default, the Title field of the new ContentDocument record is the same as the name of the file (without the extension). In the example, the title is astro. Use the --title flag to give it a new title:
1sf data create file --file astro.png --title "Astro Running" --target-org new-scratch-orgBy default, the uploaded file isn’t attached to a Salesforce record, such as an account or contact. If you know the ID of the record to which you want to attach the uploaded file, specify it with the --parent-id flag. This example attaches the file to a contact because the ID starts with 003:
1sf data create file --file astro.png --parent-id 003O300000WLdtwIAD --title "Astro Running" --target-org new-scratch-org