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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With