SharepointSite
objectA SharePoint site and document library. Remote paths are relative to the library root, e.g. 'Reports/2026/summary.xlsx'; local paths are relative to the project.
- Kind Object
- Library Sharepoint
- Category Messaging & Integrations
- Functions 8
How to get one
- Sharepoint .connect()
- SharepointSite
local sharepointSite = Sharepoint.connect(siteUrl)Returned by
Functions
-
useLibraryself Switches to another document library of the site. -
uploadself Uploads a project file to the library, replacing the remote file if it exists. -
downloadself Downloads a library file into the project, creating missing local folders and overwriting an existing local file. -
listSharepointItem[] Lists the files and subfolders directly in a folder (not recursive); "" is the library root. -
existsboolean Returns true when a file or folder exists at the path, false when SharePoint answers 404. -
createFolderself Creates a folder and any missing parent folders. -
moveself Moves and/or renames a file or folder within the library. -
deleteself Deletes a file or a folder with everything in it; SharePoint moves it to the site recycle bin, so it can be restored there.
useLibrary()
Section titled “useLibrary()”sharepointSite.useLibrary(name: string)→self Switches to another document library of the site. The name is matched without regard to case against the library's display name and the name in its URL ("Documents" or "Shared Documents"). Raises an error listing the available libraries when none matches. All later calls on this site use that library.
Parameters
-
namestring - Library name
Returns
Example
site.useLibrary("Contracts")print(#site.list(""))upload()
Section titled “upload()”sharepointSite.upload(localFile: string, remoteFile: string)→self Uploads a project file to the library, replacing the remote file if it exists. Files are sent in a single request, which SharePoint limits to 250 MB; larger files fail with an HTTP error. The local path must be a file inside the project (otherwise "Local path must be a file inside the project"); it is fetched from the Reflex server first when it is not in the workspace. Create missing folders yourself with createFolder.
Parameters
-
localFilestring - Local file, relative to the project
-
remoteFilestring - Remote file path in the library
Returns
Example
site.createFolder("Reports/2026")site.upload("output/summary.xlsx", "Reports/2026/summary.xlsx")download()
Section titled “download()”sharepointSite.download(remoteFile: string, localFile: string)→self Downloads a library file into the project, creating missing local folders and overwriting an existing local file. The local path must be inside the project. Raises an error ("HTTP 404 itemNotFound") when the remote file does not exist.
Parameters
-
remoteFilestring - Remote file path in the library
-
localFilestring - Local file, relative to the project
Returns
Example
site.download("Inbox/orders.csv", "input/orders.csv")list()
Section titled “list()”sharepointSite.list(folder: string)→SharepointItem[] Lists the files and subfolders directly in a folder (not recursive); "" is the library root. Every page of results is read, so large folders are complete. Each item's path can be passed to download, move, exists and delete. Raises an error when the folder does not exist.
Parameters
-
folderstring - Remote folder path
Returns
Fields of SharepointItem
-
namestring - file or folder name
-
pathstring - path relative to the library root; pass it to download, move or delete
-
folderboolean - true for a folder, false for a file
-
sizenumber - size in bytes
-
webUrlstring - browser URL of the item
-
lastModifiedstring - last modified date in ISO 8601
Example
for _, item in ipairs(site.list("Inbox")) do if not item.folder and item.name:match("%.csv$") then print(item.path, item.size, item.lastModified) endendexists()
Section titled “exists()”sharepointSite.exists(path: string)→boolean Returns true when a file or folder exists at the path, false when SharePoint answers 404. Other errors (no access, sign-in problems) are raised.
Parameters
-
pathstring - Remote path
Returns
Example
if not site.exists("Reports/2026") then site.createFolder("Reports/2026")endcreateFolder()
Section titled “createFolder()”sharepointSite.createFolder(path: string)→self Creates a folder and any missing parent folders. Folders that already exist are left alone, so it is safe to call repeatedly.
Parameters
-
pathstring - Remote folder path
Returns
Example
site.createFolder("Archive/2026/Q1")move()
Section titled “move()”sharepointSite.move(from: string, to: string)→self Moves and/or renames a file or folder within the library. The destination path includes the new name, and its parent folder must already exist (createFolder). Raises an error when the destination already exists or the source is missing.
Parameters
-
fromstring - Remote source path
-
tostring - Remote destination path, including the new name
Returns
Example
site.move("Inbox/orders.csv", "Processed/orders-2026-05.csv")delete()
Section titled “delete()”sharepointSite.delete(path: string)→self Deletes a file or a folder with everything in it; SharePoint moves it to the site recycle bin, so it can be restored there. Refuses to delete the library root (""). Raises an error when the path does not exist.
Parameters
-
pathstring - Remote path
Returns
Example
site.delete("Inbox/orders.csv")