javascript - Google Drive NodeJS api返回已删除的文件

标签 javascript node.js rest express google-drive-api

我在我的应用程序中使用谷歌驱动器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:

  1. trashing: https://developers.google.com/drive/api/v2/reference/files/trash <- this is V2 API, I don't know if it works on v3
  2. 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/

相关文章:

javascript - nodejs 加密的 Hmac sha256 base64 和 CryptoJS 不同

javascript - 如何使用 AngularJS 搜索 JSON?

javascript - 为什么传递的函数是否带参数对 Mocha 的 `before()` 很重要?

node.js - 从 Postgres - Node/React 返回图像 url 到前端

.net - 在 .Net 中编写 RESTful 服务 "client"的最佳方法?

java - 具有二进制数据的 REST 服务

security - 如何在 RESTful 应用程序中防止 CSRF?

javascript - 在输入字段上使用 vue 指令(v-model、@input)时,vue 中的数据列表出现意​​外行为?

javascript - 如何检测 google maps PolyLine 叠加层上的点击事件?

Node.js 服务器的 Socket.IO 解释?