在Google云端硬盘中删除和重命名事件

时间:2016-12-21 17:13:27

标签: google-app-engine google-drive-api

我正在为我们的webapp工作,我们从服务器创建谷歌驱动器文件



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();




我已将Drive UI Integration配置为从Google驱动器触发新的和开放的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"
		  }
		}




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

1 个答案:

答案 0 :(得分:0)

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

我在SO question中发现有人使用Apps Activity API来解决此问题。

有关详细信息,请查看此thread

相关问题