Created
January 17, 2018 00:00
-
-
Save Musinux/9945da1a2afd284cef5ec0377f4b2460 to your computer and use it in GitHub Desktop.
nodejs drive api v3 fetch children files from folder
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const GoogleAuth = require('google-auth-library') | |
const OAuth2Client = GoogleAuth.OAuth2Client | |
const google = require('googleapis') | |
const clientId = '<YOUR_CLIENT_ID>' | |
const clientSecret = '<YOUR_CLIENT_SECRET>' | |
const redirectUri = '<Your URI Callback>' | |
const oauth2Client = new OAuth2Client(clientId, clientSecret, redirectUri) | |
// your oauth method, see documentation | |
const drive = google.drive({ version: 'v3', auth: oauth2Client }) | |
/** | |
From now on, if you want to get the list of children, you must use a query string, in the form of | |
"'IDofYourFolder in' parents" where "in parents" indicates that Drive should look into IDofYouFolder | |
**/ | |
drive.files.list({ | |
q: `'${googleFolderId}' in parents` | |
}, (err, data) => { | |
if (err) throw err | |
console.log('your files', data) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@Calvin087 it's named Promises, so you can look here and there for some explanations and examples. If you need some links to learn node.js, go to my own list on github you may find some interesting information.