Google云端硬盘无服务器解决方案的观看更改

时间:2019-08-22 07:26:07

标签: firebase google-cloud-firestore google-drive-api google-cloud-functions serverless

我想创建一个由Google云端硬盘“ Changes:watch”触发的firebase函数:

https://developers.google.com/drive/api/v3/reference/changes/watch

我知道我可以使用Google云存储来做到这一点,但对于我的用例来说,这是让我的用户监视和上传文件更改的最佳用户体验。

我希望这是一种无服务器的解决方案,以节省运行一直在等待/轮询的服务器的成本。理想情况下,在将数据解析到Firestore中时,可以使用触发器在firebase函数中完成

1 个答案:

答案 0 :(得分:0)

您可以使用Google Drive Push Notifications API

设置您的WebHook以指向您的Firebase函数终结点:

POST https://www.googleapis.com/drive/v3/changes/watch
Authorization: Bearer auth_token_for_current_user
Content-Type: application/json

{
  "id": "4ba78bf0-6a47-11e2-bcfd-0800200c9a77", // Your channel ID.
  "type": "web_hook",
  "address": "<your-function-endpoint>", // Your receiving URL.
  "token": "target=myApp-myChangesChannelDest", // (Optional) Your channel token.
}
相关问题