在Google Drive中删除和重命名事件



我正在为我们的WebApp创建一个从服务器创建Google Drive文件的功能

Drive service =  getServiceForLoginUser();
com.google.api.services.drive.model.File fileMetadata = new com.google.api.services.drive.model.File();
fileMetadata.setTitle(getDefaultName());
fileMetadata.setMimeType(APPLICATION_VND_GOOGLE_APPS_DRIVE_SDK);
        com.google.api.services.drive.model.File.Thumbnail thumbnail = buildThumbnail(driveType);
fileMetadata.setThumbnail(thumbnail);
        
com.google.api.services.drive.model.File googleFile = service.files().insert(fileMetadata)
                .setFields("id")
                .execute();

我已经配置了驱动器UI集成以触发Google Drive的新和打开的URL流。我还发布了一个带有以下清单的Chrome应用程序。

"name" : "classflowtest",
		"version" : "3.5",
		"manifest_version" : 2,
		"icons": {
		"128": "icon_128.png"
		 },
		"description" : "description_text",
		"container" : "GOOGLE_DRIVE",
		"api_console_project_id" : "146081768739",
		"gdrive_mime_types": {
		  "http://drive.google.com/intents/opendrivedoc": [
			{
			  "type": ["image/png", "image/jpeg", "image/gif", "html","application/vnd.google.drive.ext-type.png",
			  "application/vnd.google.drive.ext-type.jpg","application/vnd.google.drive.ext-type.gif","application/vnd.google.drive.ext-type.html"],
			  "href": "https://mywebappurl",
			  "title" : "Open",
			  "disposition" : "window"
			}
		  ]
		},
		"app" : {
		  "launch" : {
		  "web_url" : "mywebappurl"
		  }
		}

所以现在我可以成功地触发新的和开放的流动。在新流程中,我首先在DB中创建一个资源,然后从应用程序服务器中创建Google Drive中的文件。因此,我在Google Drive中创建的每个条目也都在我们的数据库中表示。我的问题是现在,如果我重命名或删除Google Drive中的文件,如何获得这些事件,以便可以在DB中进行必要的更改?

检查Changes: list是否可以为您提供帮助。它将列出您驱动器中的所有更改。但是很难过滤结果。要获取已删除的文件,您必须将includeRemoved参数指定为true。因此,如果您在重命名或删除文件之前知道文件的fileID,则更容易获取文件。

我在这个问题中发现,有人使用应用程序API API解决此问题。

有关更多信息,请检查此线程。

最新更新