firebase - 适用于 Google Drive 的无服务器解决方案观察变化

标签 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 云存储来做到这一点,但对于我的用例来说,让 Google 云端硬盘监视并上传文件更改对于我的用户来说是最好的用户体验。

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

最佳答案

您可以使用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.
}

关于firebase - 适用于 Google Drive 的无服务器解决方案观察变化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57604087/

相关文章:

firebase - 如何将拨动开关按钮从 flutter 添加到 firebase firestore 数据库

firebase - Firestore 单字段索引豁免限制

php - 使用 google-drive-api 创建一个子文件夹并使用 PHP 返回 id

google-apps-script - 远程编辑谷歌文档

Firebase auth - 从网站中的应用程序登录用户

android - 应用程序在调试时运行时如何禁用 Firebase 崩溃报告?

swift - 使用 Swift 5 在 Firestore 中获取字段的旧值

google-drive-api - Google Drive v3 - 如何检查文件夹是否位于根目录?

google-analytics - Firebase 尝试加载 http,但被 App Transport Security 阻止

javascript - 将 Firebase 方法转换为异步等待