Sharepoint: Upload File
Controlled node
Overview
Uploads files to Microsoft SharePoint. This node supports uploading text files, CSV tables, and Word documents to a specified SharePoint drive and folder. The node requires an active SharePoint connection with appropriate write permissions to the target location.
Inputs
| Input | Type | Description | Default |
|---|---|---|---|
| Run | Event | Triggers the file upload operation. | - |
| Data | Data | The content to upload. For text files, provide a string. For CSV files, provide tabular data (array of objects or arrays). For DOCX files, provide text or markdown content. | - |
| File Name | Data | The name of the file to create in SharePoint (without extension). | - |
| File Type | Enum | The file format: txt (Text File), csv (CSV Table), or docx (Word Document). | txt |
| Connection | Data | The SharePoint connection to use for uploading. Configure via the panel UI connection selector. | - |
| Connection Data | Data | Contains the target drive and folder path information. Set via the folder picker in the panel UI. | - |
Outputs
| Output | Type | Description |
|---|---|---|
| Done | Event | Fires when the upload operation completes, regardless of success or failure. |
| Output | Data | Returns true if the file was uploaded successfully, false if the upload failed. |
Runtime Behavior and Defaults
This is a controlled node that executes when triggered by the Run event. The node performs the following actions:
- Connection Validation: Verifies that a valid SharePoint connection is selected and that the connection has permitted drives configured. If no folder is specified in the connection data, the file uploads to the root of the permitted drive.
- File Preparation: Converts the input data to the appropriate format based on the selected file type:
- TXT: Converts data to plain text string using
advancedToString - CSV: Converts tabular data to CSV format using Papa Parse with headers enabled
- DOCX: Converts text/markdown to Word document format using
markdownToDocx
- TXT: Converts data to plain text string using
- Upload: Uploads the file to the specified SharePoint drive and folder using the Microsoft Graph API via
msSharepointService.uploadFile. - Completion: Triggers the Done event and sets the Output boolean to indicate success or failure.
Important Notes:
- The node requires the SharePoint connection to have write permissions to the target drive.
- File names are automatically appended with the appropriate extension based on the selected file type.
- If the upload fails due to permissions, connection issues, or invalid data, the Output will return
falseand the error will be logged.
Example Usage
Basic CSV Upload
- Connect a Start node or trigger to the Run input.
- Set the File Name to "Sales_Report_2024".
- Set the File Type to "csv".
- Connect a database query node or data transformation output to the Data input providing an array of records.
- Select a SharePoint connection and target folder in the panel UI.
- Connect the Done event to subsequent nodes to continue the workflow after upload.
- Use the Output data in an If node to check if the upload succeeded (
true) or handle failures (false).
Uploading AI-Generated Documents
Connect an AI Write node's text output to the Data input to upload AI-generated content directly to SharePoint. Set the File Type to "docx" to create a Word document from the generated text, or "txt" for a plain text file.