@premiumfastnet/google-drive
v1.13.0
Published
![npm](https://img.shields.io/npm/v/@premiumfastnet/google-drive) ![npm](https://img.shields.io/npm/dm/@premiumfastnet/google-drive) ![GitHub Release Date](https://img.shields.io/github/release-date/Premium-Fast-Network/node-google-drive) ![GitHub issues]
Downloads
6
Readme
Google Drive (NodeJS)
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
- Setup Credentials API (Rename
credentials.sample.js
tocredentials.js
) - Generate Auth Url
- Validate Auth Code
- Set and Get Token (User)
- Refresh Token Manually (User)
- Check Quota (User)
- List Files (User)
- Get, Copy, Delete Files and Empty Trash (User)
- Share Files to Email (Private) or Public
- Create and Delete Directory
- Upload Single File With Progress Progress Bar
- Download Files With Progress
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