@premiumfastnet/google-drive

1.13.0 • Public • Published

Google Drive (NodeJS)

npm npm GitHub Release Date GitHub issues GitHub pull requests NPM

Simple Interaction to Google Drive using NodeJS + Promises

Important

  • This script make without guarantee.
  • If you found error or something else, please make a new issue or pull request.

Documentation

Installation

  • NPM
npm i @premiumfastnet/google-drive
  • Yarn
yarn add @premiumfastnet/google-drive

Feature and Example Code

To-DO

  • [x] Get Detail Disk Quota
  • [x] Get List Files
  • [x] Get, Copy, Delete Files
  • [x] Empty Trash
  • [x] Share Files to Email (Private) or Public
  • [x] Create and Delete Directory
  • [x] Upload Single File With Progress Bar
  • [x] Download Files With Progress

Best Practise How to Use Nested Function

  • This example will explain how to generate a new token and continue to next request function
  • We can define multiple function in one way.
  • In first time we set a user token, then we make a function for check quota, then all of this will execute after we refresh a token manually.
const gd = new GoogleDrive({
    clientId: credentials.clientId,
    clientSecret: credentials.clientSecret,
    scopes: credentials.scopes,
});

// set user token
const setToken = gd.setToken(credentials.user);

// check quota
const quota = () => {
    gd.checkQuota()
        .then((res) => {
            // your function for save new quota to database
            console.log(res.data);
        })
        .catch((err) => {
            console.log(err);
        });
};

// refresh token manual
const refresh = gd.refreshToken();

refresh
    .then((res) => {
        gd.setToken(res.data);
    })
    .then(() => {
        quota();
    })
    .catch((err) => {
        console.log(err);
    });

INFO

  • By: Juni Yadi @ Premium Fast Network
  • License: MIT

Readme

Keywords

none

Package Sidebar

Install

npm i @premiumfastnet/google-drive

Weekly Downloads

0

Version

1.13.0

License

MIT

Unpacked Size

12.7 kB

Total Files

6

Last publish

Collaborators

  • juniyadi