UploadDocument
Uploads a document to a SharePoint document library. Essential for adding new files to SharePoint for collaboration and storage.
Stored Procedure-Specific Information
Examples follow.To upload a file from a local path to a SharePoint library:
/* URL = https://mysite.sharepoint.com */ EXEC UploadDocument RelativeUrl = 'Shared Documents/Cdata/', InputFilePath = 'C:/Users/User/Documents/Demo1234.txt', FileName = 'Demo1234.txt';
To upload a file to the root of a document library:
/* URL = https://mysite.sharepoint.com */ EXEC UploadDocument RelativeUrl = '/Shared Documents/', InputFilePath = 'C:/path/to/file.json', FileName = 'UploadedFile.json';
To upload a file to a subsite's document library:
/* URL = https://mysite.sharepoint.com/sites/TestSite */ EXEC UploadDocument RelativeUrl = '/Shared Documents/Subfolder/', InputFilePath = 'C:/Users/User/Documents/report.pdf', FileName = 'monthly_report.pdf';
To upload large files with chunk upload:
To upload large files, you can activate the chunk upload logic by setting the ChunkSize input to a positive value lower than 250, which is the maximum upload size limit for SharePoint.
- Suggested Chunk Size: SharePoint recommends a chunk size of 10MB.
- Usage Limits: Uploading large files with small chunks may exceed usage limits, causing SharePoint to throttle further requests from that client temporarily.
/* Upload large file with chunk upload */ EXEC UploadDocument RelativeUrl = 'Shared Documents/', InputFilePath = 'C:/Users/User/Documents/large_file.zip', FileName = 'large_file.zip', ChunkSize = '10';
Input
| Name | Type | Required | Accepts Input Streams | Description |
| RelativeUrl | String | True | False | The relative path of the folder where the file will be uploaded. This path is based on the base URL specified in the SharePoint connection properties. Examples: Root folder:Shared Documents Sub-folder:Shared Documents/MyFolder If the connection property points to a site collection, the relative URL corresponds to a path on the base site. If it points to a specific site, the relative URL is relative to that site. |
| InputFilePath | String | False | False | The local file path of the file to be uploaded to SharePoint. |
| FileName | String | True | False | The name of the file to be created in SharePoint, including its file extension (such as 'Report.pdf'). |
| Overwrite | String | False | False | A Boolean value specifying whether to overwrite an existing file with the same name. Set to 'true' to replace the file if it exists. |
| Content | String | False | True | The file content as an InputStream. This parameter is used when InputFilePath is not specified. |
| ChunkSize | Int | False | False | Defines the chunk size (in MB) for multipart uploads. This is useful for uploading large files in smaller parts. |
Result Set Columns
| Name | Type | Description |
| Success | Boolean | Indicates whether the upload operation was successful. Returns 'true' for success and 'false' for failure. |
| Id | String | A unique identifier returned after successfully uploading the file. |