0.1.1 • Published 1 year ago

node-gdrive v0.1.1

Weekly downloads
7
License
MIT
Repository
github
Last release
1 year ago

node-gdrive

Upload file to google drive

Installation

With npm do:

npm install node-gdrive

Use command line global:

npm install node-gdrive -g

Config

gdrive token:get # generator new token

Usage

Node project

const Drive = require("node-gdrive");

// Get token 
const drive = new Drive();
const authUrl = drive.generateAuthUrl();
console.log(`Please go to ${authUrl}`);

var code = '4/1ARtbsJpwJLAnoUT2stmrXABWcmzdvnuF6j_mV3f_ELNQcOrzyqgVz1j0o04';
var token = await drive.reedemCode(code);

// upload file
let filePath = 'foo.txt';

var upload = drive.upload(filePath, {share: true});
upload.on('*', (event, data) => {
  console.log(event, data);
});

// Download file
let fileId = "1eoAgH8xgBkkUDXkTdyPSHSbaJViv33oX";

drive
  .download(fileId, {
    resumable: true, // Resume download session
    force: false, // Override file if exists
    output: './tmp/', // Dir or filepath to save file
  })
  .then(file => {
    console.log("file", file);
  })
  .catch(err => {
    console.error("err", err);
  });

Commands line

gdrive upload file.txt --share user@gmail.com # upload and share file

gdrive donwload 1eoAgH8xgBkkUDXkTdyPSHSbaJViv33oX # download file

gdrive --help

License

MIT

0.1.1

1 year ago

0.1.0

1 year ago

0.0.18

1 year ago

0.0.17

4 years ago

0.0.12

4 years ago

0.0.13

4 years ago

0.0.14

4 years ago

0.0.15

4 years ago

0.0.16

4 years ago

0.0.11

5 years ago

0.0.10

5 years ago

0.0.9

5 years ago

0.0.8

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago