DownloadDocument
Downloads a document from a SharePoint document library. Either RemoteFile (with Library, or a full SharePoint URL) or UniqueId must be specified to identify the file.
Stored Procedure-Specific Information
To execute this procedure, enter:EXEC DownloadDocument File='C:\path\to\local_file.txt', Library='Shared Documents', RemoteFile='test/my_file.txt'
Input
| Name | Type | Required | Accepts Output Streams | Description |
| File | String | False | False | The local file path where the downloaded document will be saved, including the filename. For example, 'C:/Users/User/Desktop/DownloadedFile.txt'. |
| Library | String | False | False | The name of the document library on the SharePoint server from which the file will be downloaded. For example, 'Shared Documents'. Required when RemoteFile is a library-relative path; not required when RemoteFile is a full SharePoint URL or when UniqueId is specified. |
| RemoteFile | String | False | False | The file's relative path within the library or its full SharePoint URL. Either RemoteFile or UniqueId must be specified. |
| UniqueId | String | False | False | The unique identifier (GUID) of the file, or a SharePoint viewer URL containing the GUID. As an alternative to RemoteFile, when specified, Library is not required. |
| Encoding | String | False | False | Specifies the character encoding format for the downloaded data. Determines how the data is read and processed.
The allowed values are NONE, BASE64. The default value is BASE64. |
| FileStream | String | False | True | The output stream to which the downloaded document will be written. Used if File is not provided. |
| ReadTimeout | String | False | False | The maximum number of seconds allowed for the download operation. If exceeded, the operation fails, unlike Timeout, which only triggers if the download stalls. |
Result Set Columns
| Name | Type | Description |
| Success | Boolean | Indicates whether the document download operation was successful. Returns 'true' for success and 'false' for failure. |
| FileData | String | Contains the downloaded file content as binary data. Only returned if neither File nor FileStream is specified. |