1.0.3 • Published 7 months ago

@zsj1029/sharepoint v1.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

sharepoint

Tymly Package npm (scoped) CircleCI CodeFactor Dependabot badge Commitizen friendly JavaScript Style Guide license

Adventures in uploading/listing/downloading documents in Microsoft SharePoint Online... using Node.js add new function fileIsExist and downloadFile

Getting Started

npm i @zsj1029/sharepoint -D
const Sharepoint = require('@zsj1029/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 }

sp.fileIsExist(path) // path like '/TechnicalCommunications/ArchitectGenesis/Guide.pdf' in SharePoint, return true or false
sp.downloadFile(path, savePath) // path like '/TechnicalCommunications/ArchitectGenesis/Guide.pdf' in SharePoint
// savePath like './download/', if not pass, will return file stream

Test

First, set these to match your SharePoint environment:

Env VariableValue
SHAREPOINT_URLThis is the site we're aiming for, so something like https://example.sharepoint.com/sites/YourSite/
SHAREPOINT_USERNAMEThe username you want to connect to SharePoint with. Note this is the full username with an @, so something like some.username@example.com
SHAREPOINT_PASSWORDAnd yup, the password to accompany SHAREPOINT_USERNAME.
SHAREPOINT_DIR_PATHPath to where the files are. e.g. /Shared Documents/General
  • Alternatively, you can edit a /.env file if you prefer (as per dotenv)

Then, run:

npm run test

License

MIT

1.0.3

7 months ago

1.0.2

7 months ago

1.0.1

7 months ago

1.0.0

7 months ago