Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Drive - How to empty trash from code (programmatically)?

Please help me to integrate a project with Google Drive. The problem is that Google Drive trash folder is never emptied, so eventually Google Drive synchronization with desktop stops working due to the lack of space.

I need either to configure the trash to not keep deleted files (preferred option) or empty it programatically from C# code (less preferred), or other programing language (last resort option) .

How do I empty Google Drive trash from code or script or whatever?

like image 724
Pine Ohio Avatar asked Feb 20 '23 12:02

Pine Ohio


1 Answers

The Google Drive API doesn't expose a method to empty the trash but it has a delete method to delete files permanently, without sending them into the trash:

https://developers.google.com/drive/v2/reference/files/delete

You can also retrieve files from trash by checking the trashed label of the Files resource and then call delete on them.

like image 172
Claudio Cherubino Avatar answered Feb 22 '23 00:02

Claudio Cherubino