How do I automatically delete a file from the Google Drive trash?

There are several articles, but I canโ€™t build the code to run it successfully.

here's one article I looked at: Permanently delete a file from Google Drive

I would like to automatically delete items in the Google Cart directory every hour or so. Prefer every 10 minutes. Google must implement this useful feature.

+5
source share
3 answers

As indicated by [ Permanently delete a file from Google Drive ], you can enable the Drive API to access this method using the Appscript application. Take a look at application quotas to ensure that your implementation can support an API call every ten minutes.

You can use this solution:

function createTimeDrivenTriggers() { ScriptApp.newTrigger('emptyThrash') .timeBased() .everyHours(1) .create(); } function emptyThrash() { Drive.Files.emptyTrash(); } 
+3
source

Just used

 function you-can-put-anything-here() { Drive.Files.emptyTrash(); } 

then added trigger in google script with email alerts. set the trigger to 1 hour, and bam to work. to call emptyTrash to turn the Drive API ON in the Advanced Google Services and Drive APIs installed in the Google Developer Console. Save the file and it works without any problems. Thanks to Rivero for the guidance.

0
source

i managed to delete the file from the terminal using the following curl command.

 curl -X Delete -H 'GData-Version: 3.0' -H 'Authorization: Bearer ya29.Ci9rA4GFUvdEbOBtjA9ZPSq9_W7klt5hmyAMf5Jq8R1EdhiJIZwYqAgnjZsWG7SdWQ' https://www.googleapis.com/drive/v2/files/0Bwhnkm8opwXBQVZ5RmZuMWVUTzg 
0
source

Source: https://habr.com/ru/post/1232146/


All Articles