将文件上传到 Google 驱动器文件夹时触发事件

Trigger event on uploading file to Google Drive folder

有没有办法监控 Google Drive 文件夹,以在新文件上传到该文件夹​​时触发 Apps 脚本(或 GCP 中的其他方式)?

Google 驱动器 api 支持 push notifications 您可以设置服务器以侦听目录中的更改。

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

{
  "id": "01234567-89ab-cdef-0123456789ab", // Your channel ID.
  "type": "web_hook",
  "address": "https ://mydomain.com/notifications", // Your receiving URL.
  ...
  "token": "target=myApp-myFilesChannelDest", // (Optional) Your channel token.
  "expiration": 1426325213000 // (Optional) Your requested channel expiration time.
}

问题是通知是否会接收到新文件已上传,或者它是否只是通知您目录名称更改之类的事情。

检查notification-events