Promise-based library for interacting with SharePoint Online.
const Sharepoint = require('@paulholden2/sharepoint')
const sp = new Sharepoint('URL HERE')
sp.authenticate()
sp.getWebEndpoint()
sp.getContents(path)
sp.createFolder(path)
sp.deleteFolder(path)
sp.createFile(options) // options = { path, fileName, data }
sp.deleteFile(options) // options = { path, fileName }
sp.createFileChunked(options) // options = { path, fileName, stream, fileSize, chunkSize }
First, set these to match your SharePoint environment:
Env Variable | Value |
---|---|
SHAREPOINT_URL |
Your test/sandbox SharePoint site https://example.sharepoint.com/sites/YourSite/ . |
SHAREPOINT_USERNAME |
User Principal Name of the user you wish to test with, e.g. john.doe@example.com . |
SHAREPOINT_PASSWORD |
Password for your SHAREPOINT_USERNAME . |
SHAREPOINT_DIR_PATH |
Path to where the files are. e.g. /Shared Documents/General . |
SHAREPOINT_LIST |
An existing list that can be tested against. |
- Alternatively, you can edit a
/.env
file if you prefer (as per dotenv)
Then, run:
npm run test