Code Monkey home page Code Monkey logo

drivetreecreator's Introduction

DriveTreeCreator.js

pretty easy way to create a ton of folder tree from google drive

License

WTFPL

Example

poster

CND

not have yet

Usage

actually i wrote a post about compares to 3 ways to get google drive tree structure

//  all code use ES6

//  step 1
//  import DriveTreeCreator to u project

import DriveTreeCreator from './DriveTreeCreator'

(async ()=>{


//  step 2
//  get Instance from DriveTreeCreator
let D = new DriveTreeCreator({
    googleAPI: {
      clientId: '',
      apiKey: '',
      folderId: '',
      owner: ''
    }
  })
  
//  step 3 
//  initialization google api environment
await D.init()

//  step 4
//  get pop page to sign in google account
!D.isSignIn() && await D.signIn()

//  step 5
//  time to roll!
let data = await D.start()
console.log(data)


})()

all of Options and Method below
lets assume u already know How that Google Drive Api Working
https://developers.google.com/drive/

Options

Name Description
scope https://developers.google.com/identity/protocols/googlescopes
default value is https://www.googleapis.com/auth/drive
inTrash list files except trash file
files google drive api list parameter ---- files
https://developers.google.com/drive/api/v3/search-files
includeTeamDriveItems google drive api list parameter
https://developers.google.com/drive/api/v3/reference/files/list
sort sort file from dir view, accept a fn,
default value is null
googleAPI.clientId https://developers.google.com/fit/android/get-api-key
googleAPI.apiKey https://developers.google.com/maps/documentation/javascript/get-api-key
googleAPI.folderId which folder do you want to get from? accept multiple folder Id use ,to segmentation like
folderIdTest,folderIdTest2,folderIdTest3
googleAPI.owner the owner of the google folder that's a point of DriveTreeCreator working
as we know , we cant get children folder or grandson folder by google drive api, cuz google not provide it
but interestingly we can use the owner parameter to replace it! like xxx@org

where i should get the owner? owner

Methods

Name Description Return
init a method from initialization google api environment
which mean u should call it after new DriveTreeCreator,immediately
and every method calling should after init finish
Promise
signIn get pop page to sign in google account Promise
signOut Sign Out User Promise
isSignIn check user Sign In state Boolean
start start to create tree view Promise
getCurrentUser start to create tree viewget user information from current sign in Object

Events

//  how to use events?
Instance.on('eventName','callbackHandler')

Name Description Return
signInStateChange user sign in state change {state:true/false}
loadProcess progress state of loading google files {process: 'start'/'end'/num, count: 0}

drivetreecreator's People

Contributors

carl-jin avatar

Stargazers

 avatar  avatar  avatar 田川 秋子 avatar  avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.