3.0.1 • Published 2 years ago

sppull v3.0.1

Weekly downloads
200
License
MIT
Repository
github
Last release
2 years ago

SPPull - simple client to pull and download files from SharePoint

NPM

npm version Downloads Build Status Gitter

Node.js module for downloading files from SharePoint document libraries.

New in version 2.7.0

  • Breaking change: Removed legacy module.exports for straightforward usage in modern JS and TypeScript
import SPPull from 'sppull';
const sppull = SPPull.download; // <-- this is an entry point
  • TSLint replaced with ESLint
  • Integration tests are migrated to new version of Mocha and fixed

New in version 2.2.0

Files streaming download:

  • Download files of any supported size
  • Effective memmory consumption while fetching large files

New in version 2.1.0

Performance in SPO and HTTPS environments is improved. Download on multiple objects is x2 faster now!

New in version 2.0.6

Smart re-download mechanism. Existing files with no changes are ignored from the download.

Supported SharePoint versions

  • SharePoint Online
  • SharePoint 2013
  • SharePoint 2016
  • SharePoint 2019

How to use

Install

npm install sppull --save-dev

Demo

How it works

Usage

const { SPPull } = require('sppull');

const context = {/*...*/};
const options = {/*...*/};

SPPull.download(context, options)
  .then(successHandler)
  .catch(errorHandler);

Arguments

Context

Additional authentication options:

Since communication module (sp-request), which is used in sppull, had received additional SharePoint authentication methods, they are also supported in sppull.

  • SharePoint On-Premise (Add-In permissions)
    • clientId
    • issuerId
    • realm
    • rsaPrivateKeyPath
    • shaThumbprint
  • SharePoint On-Premise (NTLM handshake - more commonly used scenario):
    • username - username without domain
    • password
    • domain / workstation
  • SharePoint Online (Add-In permissions):
    • clientId
    • clientSecret
  • SharePoint Online (SAML based with credentials - more commonly used scenario):
  • ADFS user credantials:
    • username
    • password
    • relyingParty
    • adfsUrl

For more information please check node-sp-auth credential options and wiki pages.

Options

Overloads / cases

  • All files with folder structure from spRootFolder
  • Files from spRootFolder folder, first hierarchy level only
  • Folders structure from spRootFolder without files
  • Files based on array of paths provided strictly works with array of files only right now
  • Files based on CAML query conditions
  • Pull for documents metadata to use it in callback's custom logic

Use case scenarios can be found on the Scenarios page. This page suggests combinations of options which are optimal for certain use cases.

successHandler

Callback gets called upon successful files download.

errorHandler

Callback gets executed in case of exception inside sppull. Accepts error object as first argument for callback.

Samples

Refer to the Scenarios page for suggested options combinations available with sppull.

Basic usage

TypeSctipt:

import { AuthConfig as SPAuthConfigurator } from 'node-sp-auth-config';
import SPPull, { ISPPullOptions, ISPPullContext } from 'sppull';

new SPAuthConfigurator().getContext().then(({ siteUrl, authOptions }) => {

  const context: ISPPullContext = {
    siteUrl: context.siteUrl,
    ...context.authOptions
  } as any;

  const options: ISPPullOptions = {
    spRootFolder: 'Shared%20Documents',
    dlRootFolder: './Downloads/Documents'
  };

  SPPull.download(context, options);

}).catch(console.log);

or ES6:

const { SPPull } = require('sppull');

const context = {
  siteUrl: "http://contoso.sharepoint.com/subsite",
  creds: {
    username: "user@contoso.com",
    password: "_Password_",
    online: true
  }
};

const options = {
  spRootFolder: "Shared%20Documents/Contracts",
  dlRootFolder: "./Downloads/Contracts"
};

/*
 * All files will be downloaded from http://contoso.sharepoint.com/subsite/Shared%20Documents/Contracts folder
 * to __dirname + /Downloads/Contracts folder.
 * Folders structure will remain original as it is in SharePoint's target folder.
*/
SPPull.download(context, options)
  .then((downloadResults) => {
    console.log("Files are downloaded");
    console.log("For more, please check the results", JSON.stringify(downloadResults));
  })
  .catch((err) => {
    console.log("Core error has happened", err);
  });

Passwords storage

To eliminate any local password storing if preferable to use any two-way hashing technique, like cpass.

Inspiration and references

This project was inspired by spsave by Sergei Sergeev and gulp-spsync by Wictor Wilén projects.

SPPull depends heavily on sp-request module and use it to send REST queries to SharePoint.

3.0.1

2 years ago

3.0.0

3 years ago

2.7.1

3 years ago

2.7.0

3 years ago

2.6.7

4 years ago

2.6.6

4 years ago

2.6.5

4 years ago

2.6.4

4 years ago

2.6.3

4 years ago

2.6.2

4 years ago

2.6.1

4 years ago

2.6.0

4 years ago

2.5.1

5 years ago

2.5.0

5 years ago

2.4.1

5 years ago

2.4.0

5 years ago

2.3.3

5 years ago

2.3.2

5 years ago

2.3.1

5 years ago

2.3.0

5 years ago

2.2.7

6 years ago

2.2.6

6 years ago

2.2.5

6 years ago

2.2.4

6 years ago

2.2.3

6 years ago

2.2.2

6 years ago

2.2.1

7 years ago

2.2.0

7 years ago

2.1.1

7 years ago

2.1.0

7 years ago

2.0.7

7 years ago

2.0.6

7 years ago

2.0.5

7 years ago

2.0.4

7 years ago

2.0.3

7 years ago

2.0.2

7 years ago

2.0.1

7 years ago

2.0.0

7 years ago

1.1.5

7 years ago

1.1.4

7 years ago

1.1.3

7 years ago

1.1.2

7 years ago

1.1.1

7 years ago

1.1.0

8 years ago

1.0.0

8 years ago

0.2.5

8 years ago

0.2.4

8 years ago

0.2.3

8 years ago

0.2.2

8 years ago

0.2.1

8 years ago

0.2.0

8 years ago

0.1.10

8 years ago

0.1.9

8 years ago

0.1.8

8 years ago

0.1.7

8 years ago

0.1.6

8 years ago

0.1.5

8 years ago

0.1.4

8 years ago

0.1.3

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago

0.0.5

8 years ago

0.0.4

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago