我正在使用 google docs api 的 V3 并试图弄清楚如何按名称在指定文件夹内搜索文件。
这就是我目前所拥有的:
function listFiles(auth) {
const drive = google.drive({version: 'v3', auth});
drive.files.list({
q: 'name = "NAMEHERE" and parents in "FOLDERID"',
pageSize: 10,
fields: 'nextPageToken, files(id, name, webViewLink)',
}, (err, res) => {
if (err) return console.log('The API returned an error: ' + err);
const files = res.data.files;
if (files.length) {
console.log('Files:');
files.map((file) => {
console.log(`${file.name} ${file.webViewLink}`);
});
} else {
console.log('No files found.');
}
});
}
Run Code Online (Sandbox Code Playgroud)