【发布时间】:2019-11-30 10:17:44
【问题描述】:
我有一个简单的 Js 方法,可以打印出我的 Google Drive 的内容。我弄乱了 Google 提供的示例,我可以随意打印某些文件夹和文件。
但我想知道是否有可能以某种方式查看来自哪个文件夹的文件。目前我只列出了文件和文件夹,还有 id 和 mime 类型,但我看不到任何属性或方法来确保哪个文件来自哪个文件夹。
有没有可能?
我的示例代码:
/**
* @param {google.auth.OAuth2} auth An authorized OAuth2 client.
*/
function listFiles(auth) {
const drive = google.drive({version: 'v3', auth});
drive.files.list({}, (err, res) => {
if (err) throw err;
const files = res.data.files;
if (files.length) {
files.map((file) => {
console.log(file);
});
} else {
console.log('No files found');
}
});
}
这会返回:
{
kind: 'drive#file',
id: 'example-id',
name: 'example-file-name',
mimeType: 'application/vnd.google-apps.folder'
}
【问题讨论】:
标签: javascript node.js google-drive-api