Google Drive SDK Push Notifications - watch changes on all files?

后端 未结 1 1140
刺人心
刺人心 2021-02-04 15:07

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 ena

1条回答
  •  攒了一身酷
    2021-02-04 15:12

    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.

    0 讨论(0)
提交回复
热议问题