Google Drive SDK推送通知 - 观看所有文件的更改? [英] Google Drive SDK Push Notifications - watch changes on all files?

查看:76
本文介绍了Google Drive SDK推送通知 - 观看所有文件的更改?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我很想知道如何启用观看云端硬盘上共享文件夹中的所有文件。我们正在研究云端硬盘监控工具,它可以保留所有更改的列表,并为整个企业云端硬盘文件夹启用报告功能。

我知道我可以使用关于新对象的通知在更改供稿中。不幸的是,您无法从Changes资源中检测到发生了什么变化



在观看文件资源时,您可以收到通知,已经改变了有关文件(父母,权限,元数据等)。这很好,但是似乎无法为Drive中的所有文件注册推送通知处理程序。文档说你总是需要提供 fileId 。这意味着要在我们的场景中为数百万个文件制作观看请求(不要提及现在或时间更新推送API频道)。

你知道任何比使用更改通知更合适的方式,并检测手动更改的内容(这是相当多的API调用,而且执行起来相当缓慢)。

解决方案

长话短说,不。



现在推送通知仅支持观看文件和更改。您可能知道,Google云端硬盘中的文件夹是带有特殊mimeType的文件。也就是说,您可以通过向文件夹发出Files.Watch()请求来观看特定的文件夹。然而,它只会告诉你直接孩子的变化,而不是递归的,这可能不是你想要的。



你可以采取的最好方法是复制将所有文件的元数据发送到您的应用程序并在发生任何更改时进行比较我知道这不是非常有效,但现在,这是你实现这一目标的唯一方法。



如果你问我,你想要的功能是创造,不可能。推送通知不仅适用于Drive API。它专为所有Google API在任何API资源上观察并检测其更改而设计。基本上,当您制作Files.Watch()请求时,它将保留Files.get()的结果副本,并让您知道何时发生任何更改。这就是为什么Files.watch有更多有用的细节的原因。对于更改,只要Changes.list()发生更改,它就会告诉您。因此,它不能告诉你什么比变更资源目前能做的更好。从它的设计,我不认为你想要的功能将被添加到Drive API。


The recently launched Push Notifications service is very cool and looks as a big improvement over polling that was previously necessary.

I am wondering though how to enable watching of all files in shared folder on Drive. We are working on Drive monitoring tool, that keeps list of all changes and enables reporting for whole enterprise Drive folders.

I am aware that I can use the notifications about new objects in Changes feed. Unfortunately, you are not able to detect the what has changed from Changes resource.

When watching File resources, you can receive notifications that say what has been changed about the file (parents, permissions, metadata etc.). This is great, however it seems that is not possible to register Push Notification handler for all files in Drive. The docs says you always need to provide fileId. That would mean to make watch requests for millions of files in our scenario (not mentioning renewing the Push API channels each now and then).

Do you know of any more suitable way than using Changes notifications and detect what has been changed manually (which is quite a lot of API calls and rather slow to do).

解决方案

Long story short, no.

Push Notification for now only supports watching on Files and Changes. As you might know, folders in Google Drive is File with special mimeType. That is, you can watch on a specific folder by making Files.Watch() request to a folder. However, it will only tell you changes in its direct children, not recursively, which is probably not what you wanted.

The best approach you could take is to make copy of all file's metadata to your application and compare it when any changes happened. I know this is not very efficient, but for now, this is the only way you could achieve this goal.

And if you ask me if the feature you want will be created, not likely. Push notifications is not only for Drive API. It is designed for all Google API to watch on any API resource and detect their changes. Basically, when you make Files.Watch() request, it keeps copy of the result of Files.get() and let you know when anything changed. That is the reason why Files.watch has a lot more useful details. For Changes, it tells you whenever there is changes in Changes.list(). Thus, it cannot tell you anything better than what Changes resource can currently do. From its design, I don't think the feature you want will be added to Drive API.

这篇关于Google Drive SDK推送通知 - 观看所有文件的更改?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆