UploadContentDocument
Uploads a document to Salesforce Content and associates it with relevant records.
Stored Procedure-Specific Information
This stored procedure uploads a ContentDocument (Salesforce Files) to Salesforce.Examples
To upload a content document (test_UploadDocumentContent_stream):
EXEC UploadContentDocument Title = 'testing', FileExtension = 'txt'To upload content document with file path:
EXEC UploadContentDocument FullPath = 'C:\Documents\myfile.pdf'To upload content document with Base64 data:
EXEC UploadContentDocument Base64Data = 'byBib2Jl', Title = 'mydocument', FileExtension = 'txt'
Parameters:
- Title - The title for the uploaded content document
- FileExtension - The file extension (e.g., 'txt', 'pdf', 'png')
- FullPath - The full path to the file to upload
- Base64Data - Base64-encoded file content
Output columns include:
- Id - The ID of the created ContentDocument
Uploading Single Files or Single Folders
To upload a single ContentDocument, specify the FullPath:EXEC UploadContentDocument FullPath = 'C:\\csv samples\\mycsvfile.csv'To upload all Content Documents in a single folder, use FolderPath:
EXEC UploadContentDocument FolderPath = 'C:\\csv samples'For Base64 data, you must specify the Base64Data, Title, and FileExtension:
EXEC UploadContentDocument Base64Data = 'byBib2Jl', Title = 't', FileExtension = 'txt'
Uploading Multi-Valued Inputs
There are several ways to upload multiple files or folders. One way is to use a temporary table, #TEMP: First insert values into temporary tables. For example:INSERT INTO ContentDocument#TEMP (FolderPath) VALUES ('C:\\TestImages')
INSERT INTO ContentDocument#TEMP (FolderPath) VALUES ('C:\\csv samples')
This inserts the values into a table in memory.
Then reference that same table when executing the stored procedure:
EXEC UploadContentDocument ContentDocuments = 'ContentDocument#TEMP'This approach has the advantage of avoiding arbitrary parameters as inputs to the stored procedure.
You can also specify multiple FullPaths using a #TEMP table or use multiple Base64 data entries.
Input
| Name | Type | Accepts Input Streams | Description |
| FullPath | String | False | The full local path to the file to upload. Required if Base64Data is not provided. Only one of FullPath or FolderPath should be specified for a single operation. |
| Base64Data | String | False | Base64-encoded string representing the contents of the file. Required if FullPath is not specified. Useful for programmatic uploads without local file access. |
| FileExtension | String | False | The file extension that indicates the content type (such as PDF, TXT, or DOCX). Required when using Base64Data to define the file contents. |
| Title | String | False | The title to assign to the ContentDocument in Salesforce. If omitted, the file name from FullPath will be used. Required when uploading using Base64Data. |
| FolderPath | String | False | Path to a local folder containing multiple files to upload in batch. Only one of FolderPath or FullPath should be used per request. |
| Description | String | False | Optional text description for the ContentDocument. Maximum length is 255 characters. |
| LinkedObjectId | String | False | The ID of the Salesforce record to associate all uploaded files with. When specified, each uploaded file will be linked to this record via a ContentDocumentLink. Can also be set per file using the ObjectId column in the ContentDocuments aggregate. |
| Content | String | True | The file content as an InputStream. Used as an alternative to FullPath or Base64Data for direct streaming uploads. |
| ContentDocuments | String | False | Accepts a temporary table name or an aggregate (JSON) containing multiple ContentDocument records for batch uploading. Each row should contain fields such as FullPath or Base64Data. |
Result Set Columns
| Name | Type | Description |
| Id | String | The ID of the newly created content version record associated with the uploaded document. |
| ContentDocumentId | String | The ID of the ContentDocument object created from the uploaded file. |
| FileIdentifier | String | Identifies the file for this result row. Contains the full file path when FullPath or FolderPath was used, or the title when Base64Data or Content stream was used. |
| Success | Boolean | Indicates whether the file upload succeeded (true) or failed (false). |
| Errors | String | Error messages returned by Salesforce if the upload failed, including error codes and descriptions. |