ADO.NET Provider for Salesforce

Build 25.0.9539

DownloadDocument

Downloads documents from Salesforce for offline access or external use.

Stored Procedure-Specific Information

This stored procedure downloads a Document from Salesforce (from the Documents object, not ContentDocument/Salesforce Files).

In the following examples, Output columns include:

  • Success - Whether the download was successful
  • FileId - The ID of the downloaded Document
  • FileData - The file content (Base64-encoded by default)
  • FileName - The name of the file (when saving to disk)
  • FullPath - The full path where the file was saved (when saving to disk)

Download by Document ID

To download a Document by its ID:

EXEC DownloadDocument Id = '0151W000002kJtPQAU'

Download to a specific file path

To download a Document and save it to a specific location:

EXEC DownloadDocument Id = '0151W000002kJtPQAU', FullPath = 'C:\\Downloads\\mydocument.pdf'

Download as Base64 data

By default, the file content is returned as Base64-encoded data in the FileData output column. To receive the raw (unencoded) content, set the Encoding parameter:

EXEC DownloadDocument Id = '0151W000002kJtPQAU', Encoding = 'NONE'

Input

Name Type Accepts Output Streams Description
Id String False Salesforce ID of the specific document to download. Required if Name or FolderId is not specified. If none are provided, all documents will be downloaded.
Name String False Name of the document to download. Can be used as an alternative to Id or FolderId. If none are provided, all documents will be downloaded.
Folderid String False Salesforce ID of the folder containing the documents to download. Useful for downloading all documents within a specific folder.
LocalPath String False Path on the local file system where the downloaded file(s) will be saved. If omitted, the file is returned in memory via the FileData output.
Encoding String False Text encoding format used when returning file data via FileData. Ignored if the file is written to disk.

The allowed values are NONE, BASE64.

The default value is BASE64.

FileStream String True Optional output stream to write file data to when LocalPath is not specified. Supports in-memory or streaming download use cases.

Result Set Columns

Name Type Description
FileId String Salesforce ID of the downloaded document.
Success String Indicates whether the download operation succeeded for the specific document (true or false).
FileName String Name of the file that was downloaded from Salesforce.
FullPath String Complete local file path, including the file name, where the document was saved.
FileData String Base64-encoded content of the downloaded file. Only returned when LocalPath is not set and data is kept in memory.
FailureMessage String If downloading multiple documents, contains error messages for any documents that failed to download.

Copyright (c) 2026 CData Software, Inc. - All rights reserved.
Build 25.0.9539