cloud-local

0.0.9 • Public • Published

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

// upload file
 
const { Upload, Download } = require("node-gdrive");
 
let filePath = 'foo.txt';
 
var upload = new Upload(filePath, {share: true});
upload.on('*', (event, data) => {
  console.log(event, data);
});
 
// Download file
let fileId = "1eoAgH8xgBkkUDXkTdyPSHSbaJViv33oX";
 
var download = new Download();
download
  .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

Package Sidebar

Install

npm i cloud-local

Weekly Downloads

1

Version

0.0.9

License

MIT

Unpacked Size

31.3 kB

Total Files

11

Last publish

Collaborators

  • khoazero123