@nocodesites/gdrive-loader
Download google a drive folder tree with document and spreadsheet contents extracted
Last updated a year ago by binocarlos .
MIT · Original npm · Tarball · package.json
$ cnpm install @nocodesites/gdrive-loader 
SYNC missed versions from official npm registry.

@nocodesites/gdrive-loader

A module that downloads a google drive folder recursively loading the contents of spreadsheets and google documents into a tree data structure.

usage

You need to have created a service account token with google and downloaded the .json file for it.

Also - you need to have given read access to a folder on google drive to that service account and have the id of the folder ready.

const fs = require('fs')
const googleDriveLoader = require('@nocodesites/gdrive-loader')

const SERVICE_ACCOUNT_TOKEN_FILE = process.env.SERVICE_ACCOUNT_TOKEN_FILE
const GOOGLE_DRIVE_FOLDER_ID = process.env.GOOGLE_DRIVE_FOLDER_ID

if(!SERVICE_ACCOUNT_TOKEN_FILE) {
  console.error(`SERVICE_ACCOUNT_TOKEN_FILE variable needed`)
  process.exit(1)
}

if(!GOOGLE_DRIVE_FOLDER_ID) {
  console.error(`GOOGLE_DRIVE_FOLDER_ID variable needed`)
  process.exit(1)
}

if(!fs.existsSync(SERVICE_ACCOUNT_TOKEN_FILE)) {
  console.error(`${SERVICE_ACCOUNT_TOKEN_FILE} file does not exist`)
  process.exit(1)
}

let serviceAccountToken = null

try {
  const serviceAccountTokenContents = fs.readFileSync(SERVICE_ACCOUNT_TOKEN_FILE, 'utf8')
  serviceAccountToken = JSON.parse(serviceAccountTokenContents)
} catch(e) {
  console.error(`error loading service account JSON: ${e.toString()}`)
  process.exit(1)
}

googleDriveLoader({
  serviceAccountToken,
  itemId: GOOGLE_DRIVE_FOLDER_ID,
  logging: true,
}, (err, results) => {
  if(err) {
    console.error(`error: ${err.toString()}`)
    process.exit(1)
  }

  console.log(JSON.stringify(results, null, 4))
})

Current Tags

  • 0.0.14                                ...           latest (a year ago)

13 Versions

  • 0.0.14                                ...           a year ago
  • 0.0.13                                ...           a year ago
  • 0.0.12                                ...           a year ago
  • 0.0.10                                ...           a year ago
  • 0.0.9                                ...           a year ago
  • 0.0.8                                ...           a year ago
  • 0.0.7                                ...           a year ago
  • 0.0.6                                ...           a year ago
  • 0.0.5                                ...           2 years ago
  • 0.0.4                                ...           2 years ago
  • 0.0.3                                ...           2 years ago
  • 0.0.2                                ...           2 years ago
  • 0.0.1                                ...           2 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 7
Dependencies (7)
Dev Dependencies (0)
None

Copyright 2014 - 2017 © taobao.org |