Loading

Insert files with Salesforce Data Loader

Publiseringsdato: Jun 9, 2026
Beskrivelse

Salesforce Data Loader allows bulk creation of Files (ContentVersion) and their associations to records (ContentDocumentLink). This article explains how to:

1. Insert files as ContentVersion objects.
2. Link those files to Salesforce records using ContentDocumentLink.

This process requires two separate Data Loader operations.

Løsning

Warning: Always back up your data before performing any data operation. Run a test with a small subset of records first. 

 

1. Prepare a CSV and perform an Insert to the ContentVersion object.

 
  1. Create a CSV with the following columns:
 
  • Title - (Required) file name
 
  • Description - (Optional) file or link description
 
  • VersionData - (Required) The complete path to the file you're uploading from your local machine or drive. Files are converted to base64 encoding on upload. This action adds approximately 30% to the file size. Example: C:\Users\jdoe\Desktop\PictureFile.jpg
 
  • PathOnClient - (Required) The complete path to the file you're uploading from your local machine or drive. 
 
  • FirstPublishLocationId - (Optional) if you are only relating the File to a single record in Salesforce, populate this with the related record's Id. This automatically creates a ContentDocumentLink to associate the file to the related record to effectively skip the 'Prepare a CSV and perform an insert to the ContentDocumentLink object to associate Files to records' steps below.
 
Notes:
 
  1. Setting FirstPublishLocationId is only applicable on the insert of new files, and the field does not accept updates.
  2. The Sharetype of the created ContentDocumentLink to the related record is Visible by Default.
  3. For more information on the CSV fields described above, see the Data Loader Guide.
 
  1. Open and Configure Data Loader to use a 'Batch Size' of 1.
  2. Select Insert and select Show all Salesforce objects.
  3. Select ContentVersion.
  4. Browse to your CSV file.
  5. Click Create or Edit a Map then select Auto-Match fields to columns.
  6. Click OK | Next | Finish.


2. Prepare a CSV and perform an insert to the ContentDocumentLink object to associate Files to records


Use Data Loader to Export Data from the 'ContentVersion' object to get 'ContentDocumentId' for your newly created Files.


Note: If you specified FirstPublishLocationId on File insert, the following steps are only necessary to associate the newly created Files to additional records in Salesforce.
 
  1. Create a CSV file with the following columns:
 
  • LinkedEntityID - (Required) ID of the related record that the file is associated with (Accounts or Opportunities).
 
  • ContentDocumentID - (Required) ContentDocumentID from the exported ContentVersion file (starts with '069').
 
 
  • Visibility - (Optional) Specifies whether this file is available to all users, internal users, or shared user. Refer to the field's 'Description' details in the guide linked above.
 
  1. Open Data Loader and click Insert.
  2. Select the Show all Salesforce objects box.
  3. Select ContentDocumentLink.
  4. Browse to your CSV file.
  5. Click Create or Edit a Map then select Auto-Match fields to columns.
  6. Click OK | Next | Finish.
 
Knowledge-artikkelnummer

000382372

 
Laster
Salesforce Help | Article