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"})
}
}
});
});
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:
- 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
edit: you could also run this: https://developers.google.com/drive/api/v3/reference/files/emptyTrash
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With