Skip to content
This repository has been archived by the owner on Jul 14, 2023. It is now read-only.
/ DriveTreeCreator Public archive

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

License

Notifications You must be signed in to change notification settings

carl-jin/DriveTreeCreator

Repository files navigation

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}

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published