我在我的应用程序中使用谷歌驱动器API。我已从谷歌驱动器中删除了文件,但 listfiles 函数仍然返回那些已删除的文件。有没有什么解决办法可以避免这种情况。这是我的 API 的功能
router.post('/', Authorise, (req, res, next) => {
const auth = req.auth;
const drive = google.drive({version: 'v3', auth});
drive.files.list({
pageSize: 10,
fields: 'nextPageToken, files(id, name)',
}, (err, rslt) => {
if(err){
res.status(500).json(err);
}
else{
const files = rslt.data.files;
if(files.length){
res.status(200).json(files);
}
else{
res.status(200).json({message: "No files found"})
}
}
});
});
最佳答案
您可以在元数据 ( https://developers.google.com/drive/api/v3/reference/files ) 中检查 bool 值“trashed”的值。
Your problem may come from the difference between trashing and deleting:
- trashing: https://developers.google.com/drive/api/v2/reference/files/trash <- this is V2 API, I don't know if it works on v3
- deleting: https://developers.google.com/drive/api/v3/reference/files/delete
编辑:你也可以运行这个: https://developers.google.com/drive/api/v3/reference/files/emptyTrash
关于javascript - Google Drive NodeJS api返回已删除的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55052536/