我想使用node.js、googleapis和google-auth-库程序包检索Google Drive上特定文件夹的内容.问题是,尽管文件夹存在并且可以使用.get方法找到,但它看起来是空的,而它不应该是空的:
drive.files.list({
q: `'${dataSource.folder_id}' in parents`,
fields: 'files(id, name, mimeType)'
}, (err, res) => {
if (err) {
console.error('Error retrieving folder contents:', err);
return;
}
const contents = res.data.files;
if (contents && contents.length > 0) {
console.log('Contents of the folder:');
contents.forEach(file => {
console.log('File Name:', file.name);
console.log('File ID:', file.id);
console.log('File Type:', file.mimeType);
console.log('---');
});
} else {
console.log('The folder is empty.');
}
});
- 身份验证工作正常,没有错误,使用不同的方法我可以看到文件夹是否存在
- 使用Google Drive API V3
- 这个文件夹绝对不是空的,里面有一个谷歌幻灯片文档,为了安全起见,我给任何有链接的人都设置了分享选项
- 该文件夹是使用API:MimeType:‘Application/vnd.google-apps.文件夹’创建的.
用例:我想在Google Drive中检索特定文件夹的文件,并且仅检索该文件夹.当用户启用Google Drive身份验证时,将以编程方式创建该文件夹
Update:个 这是一个权限问题,我错过了:‘https://www.googleapis.com/auth/drive.readonly’.但是,这意味着我现在可以从用户那里检索所有文件,而我只想访问特定的文件夹.Is this even possible?