[英]Google DRIVE API V3 - Get a root folder ID with nodejs
I need to get root folder id and filter folders which have root folder as their parent folder. 我需要获取根文件夹ID和过滤器文件夹,其中根文件夹作为其父文件夹。 Using Nodejs and google drive API v3 .
使用Nodejs和google drive API v3。 This is my code and how I change this code to get root folderId?
这是我的代码以及如何更改此代码以获取root folderId?
const service = google.drive('v3'); service.files.list({ auth: client2, fields: 'nextPageToken, files(id, name, webContentLink, webViewLink, mimeType, parents)' }, (err, res) => { if (err) { console.error('The API returned an error.'); throw err; } const files = res.data.files; if (files.length === 0) { console.log('No files found.'); } else { console.log('Files Found!'); for (const file of files) { console.log(`${file.name} (${file.id})`); }
The folder id of the root folder is "root". 根文件夹的文件夹ID是“root”。 The file.list method has an option parameter called q which is used for searching.
file.list方法有一个名为q的选项参数,用于搜索。
service.files.list({auth: auth,
resource: { parents: [ folderId ] },
q: "'root' in parents",
fields: '*',
spaces: 'drive',
pageToken: pageToken,
}
This code is kind of a guess as i dont have the power to test node on this machine. 这段代码是一种猜测,因为我没有权力在这台机器上测试节点。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.