Automatically delete file from Google Drive trash

前端 未结 3 2006
夕颜
夕颜 2020-12-31 16:13

There are several articles, but I am not able to put a code together to run it successfully.

One article I have looked at: Permanently delete file from google drive<

相关标签:
3条回答
  • 2020-12-31 16:27

    As stated on [ Permanently delete file from google drive ], you can enable the Drive API in order to get access to the method, through Appscript. Take a look at appscript quotas to ensure that your implementation can support calling the API every ten minutes.

    You can use this solution:

    function createTimeDrivenTriggers() {
      ScriptApp.newTrigger('emptyThrash')
          .timeBased()
          .everyHours(1)
          .create();
    }
    
    function emptyThrash()
    {
      Drive.Files.emptyTrash();
    }
    
    0 讨论(0)
  • 2020-12-31 16:34

    Just used

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

    then added trigger in google script with email alerts. set trigger to 1 hour and bam it works. to call emptyTrash, Had to enable Drive API to ON under Advanced Google Services and Drive API ENABLED under Google Developer Console. Save the file and it ran without any issues. Thanks Rivero for guidance.

    0 讨论(0)
  • 2020-12-31 16:46

    i succeeded deleting a file from terminal using 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 讨论(0)
提交回复
热议问题