Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google drive nodejs api returns deleted files

I am using google drive api in my application. I have deleted the files from google drive but still listfiles function returns those deleted files. Is there any solution to avoid this. Here is function of my 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"})
        }
    }
});

});

like image 962
Anmol Middha Avatar asked Sep 09 '26 21:09

Anmol Middha


1 Answers

You can check in the Metadata (https://developers.google.com/drive/api/v3/reference/files) the value of the boolean '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

edit: you could also run this: https://developers.google.com/drive/api/v3/reference/files/emptyTrash

like image 82
Quentin C Avatar answered Sep 11 '26 11:09

Quentin C



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!