# @zsj1029/sharepoint

> Trying to upload/list/download/fileisexist file in Microsoft SharePoint, using Node.js, and forked from @wmfs/sharepoint

Latest version **1.0.3** (published 2023-10-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install @zsj1029/sharepoint
pnpm add @zsj1029/sharepoint
yarn add @zsj1029/sharepoint
bun add @zsj1029/sharepoint
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2023-10-19 |
| First published | 2023-10-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 66.8 KB |
| Known vulnerabilities | 0 (+30 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 1 |
| Author | zsj1029 |
| Maintainers | zsj1029 |
| Keywords | sharepoint, download, fileisexist, package |

## Links

- npm: https://www.npmjs.com/package/@zsj1029/sharepoint
- Repository: https://github.com/zsj1029/sharepoint
- Homepage: https://github.com/zsj1029/sharepoint#readme
- Issues: https://github.com/zsj1029/sharepoint/issues
- npm.io page: https://npm.io/package/@zsj1029/sharepoint

## Dependencies (2)

- [axios](https://npm.io/package/axios.md) 1.5.1
- [node-sp-auth](https://npm.io/package/node-sp-auth.md) 3.0.7

## Recent versions

- 1.0.3 (latest) — 2023-10-19
- 1.0.2 — 2023-10-19
- 1.0.1 — 2023-10-18
- 1.0.0 — 2023-10-18

## README

# sharepoint

[![Tymly Package](https://img.shields.io/badge/tymly-package-blue.svg)](https://tymly.io/)
[![npm (scoped)](https://img.shields.io/npm/v/@wmfs/sharepoint.svg)](https://www.npmjs.com/package/@wmfs/sharepoint)
[![CircleCI](https://circleci.com/gh/wmfs/sharepoint.svg?style=svg)](https://circleci.com/gh/wmfs/sharepoint)
[![CodeFactor](https://www.codefactor.io/repository/github/wmfs/sharepoint/badge)](https://www.codefactor.io/repository/github/wmfs/sharepoint)
[![Dependabot badge](https://img.shields.io/badge/Dependabot-active-brightgreen.svg)](https://dependabot.com/)
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)
[![license](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/wmfs/sharepoint/blob/master/README.md)

> Adventures in uploading/listing/downloading documents in Microsoft **SharePoint Online**... using Node.js
> add new function fileIsExist and downloadFile

## <a name="gettingStarted"></a>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
```

## <a name="test"></a>Test
First, set these to match your SharePoint environment:

| Env Variable | Value |
| ------------ | ----- |
| `SHAREPOINT_URL` | This is the site we're aiming for, so something like `https://example.sharepoint.com/sites/YourSite/` |
| `SHAREPOINT_USERNAME` | The username you want to connect to SharePoint with. Note this is the full username with an `@`, so something like `some.username@example.com` |
| `SHAREPOINT_PASSWORD` | And yup, the password to accompany `SHAREPOINT_USERNAME`. |
| `SHAREPOINT_DIR_PATH` | Path to where the files are. e.g. `/Shared Documents/General ` |

* Alternatively, you can edit a `/.env` file if you prefer (as per [dotenv](https://www.npmjs.com/package/dotenv))

Then, run:
```
npm run test
```

## <a name="license"></a>License
[MIT](https://github.com/wmfs/sharepoint/blob/master/LICENSE)

---
_Source: https://npm.io/package/@zsj1029/sharepoint · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
