小编Abs*_*ity的帖子

如何按名称搜索特定文件夹内的文件 Google Docs API

我正在使用 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)

google-api node.js google-drive-api

3
推荐指数
1
解决办法
2177
查看次数

标签 统计

google-api ×1

google-drive-api ×1

node.js ×1