DownloadFile
Retrieves and downloads a specified file from OneDrive storage to the local or application context.
Stored Procedure Specific Information
Microsoft OneDrive allows only a small subset of columns to be used in the Exec query. Either ResourcePath or ResourceId is required to download the file. Typically, these columns can only be used with the = comparison.
If the file is present in the root folder of a OneDrive account, mention the file name directly for the value of ResourcePath.
For example:
EXECUTE DownloadFile ResourcePath = 'Book.xlsx', LocalFile = 'D:\\Desktop\\Book.xlsx'
If the file is present inside a child folder of a OneDrive account, you need to specify the path of the file, starting from the child folder name, for the value of ResourcePath.
For example:
EXECUTE DownloadFile ResourcePath = 'Notebooks/test.png', LocalFile = 'D:\\Desktop\\test.png'
You can also download the file by providing the file's ResourceId.
For example:
EXECUTE DownloadFile ResourceId = '01CYQN2MFPR6NIWVZNMNFL3SL4E3KF7IHY', LocalFile = 'D:\\Desktop\\test.png'
Input
| Name | Type | Required | Description |
| ResourcePath | String | False | Path to the file resource to be downloaded. Either ResourcePath or ResourceId must be provided to locate the file. |
| ResourceId | String | False | Unique identifier of the file to download. Either ResourceId or ResourcePath must be provided. |
| DriveId | String | False | ID of the drive containing the resource. Required only if the resource is in a drive other than the current user's default drive. |
| LocalFile | String | False | Local file system path, including the file name, where the downloaded file should be saved. Leave empty to return the file content in memory instead. |
| Encoding | String | False | Specifies the encoding format for the downloaded file content if returned in memory. Applies only when LocalFile is left empty.
使用できる値は次のとおりです。NONE, BASE64 デフォルト値はBASE64です。 |
| Overwrite | String | False | Set to 'true' to overwrite an existing file at the specified LocalFile path. If 'false', the download fails if the file already exists. |
| Version | String | False | Specifies a particular version of the file to download. Leave blank to download the latest version. |
| UserId | String | False | ID of the user who created the file version. Required only when downloading a specific version. |
Result Set Columns
| Name | Type | Description |
| FileData | String | Returns the file content as a byte stream or encoded string if LocalFile is empty. Format depends on the specified Encoding input. |
| Success | String | Indicates whether the file was downloaded successfully. Returns success status or error details. |