本文介绍了永久删除谷歌驱动器中的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用谷歌脚本永久删除谷歌驱动器上的文件
我只找到方法setTrashed。它将文件移入垃圾箱,但是如何永久移除文件 解决方案

Apps脚本可以访问Google API,但您需要在使用它们之前明确地启用它们。



Drive API可用于删除文件。





但这是一个死路一条,因为它没有显示您拥有的Apps Script项目。


How permanently delete file on google drive using google scriptI find only method setTrashed. It moved file into Trash, but how remove file permanently

解决方案

Apps Script has the ability to access Google API's, but you need to explicitly enable them before they can be used.

The Drive API, can be used to delete a file.

Drive API - Delete

The Drive API method is Remove method instead of Delete.

To enable the Drive API, open the Resources menu, then choose the Advanced Google Services, and a menu will pop up. You need to click the Drive API service. Make sure that the green "ON" text is showing.

Once you've done that, you can use the auto-complete in the code editor to see what is available for methods. When you type the word "Drive" in the code editor, then enter a period, a context menu will appear. Then you can choose Files, etc.

Drive.Files.remove(fileId);

NOTE:

Take note of the link: Google Developers Console

You must visit your Console, and enable the services there also. And it looks like the only way you can get to your Apps Script Project in the Console is through the link in that Advanced Google Services pop up window. Going to the Google console without the correct project number in the URL fails to show your Apps Script project.

You can get to the console with:

Google Console

But that is a dead end because it doesn't show the Apps Script projects that you own.

这篇关于永久删除谷歌驱动器中的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 17:58