我想制作一个由 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/