Permanently delete a file from Google Drive

How to permanently delete a file in Google Drive using google script I find only the setTrashed method. He moved the file to the trash, but how to permanently delete the file

+8
google-drive-sdk google-apps-script google-docs-api
source share
1 answer

Script applications have the ability to access the Google APIs, but you need to explicitly enable them before using them.

Drive API can be used to delete a file.

API Driver - Remove

API method Delete instead of Delete .

To enable the drive’s API, open the "Resources" menu, then select "Google Advanced Services" and a menu will appear. You need to click the Drive API service. Make sure that the green text "ON" is displayed.

enter image description here

Once you do this, you can use autocomplete in the code editor to find out what is available for the methods. When you enter the word "Disk" in the code editor, enter the period, a context menu will appear. Then you can select Files , etc.

Drive.Files.remove(fileId); 

Note:

Pay attention to the link: Google Developers Console

You should visit the console and enable services there. And it looks like you can access the Apps Script project in the Console using the link in the Advanced Google Services pop-up window. Going to the Google console without the correct project number in the URL does not display the Apps Script project.

You can go to the console:

Google console

But this is a dead end because it does not show the Apps Script projects that you have.

+15
source share

All Articles