Webhook
约 743 字大约 2 分钟
2025-05-02
指南简介
- 实时监控网盘变化。
什么是 webhook?
- webhook 是 cd2 专门为网盘监控响应打造的一个功能。
- 开启 webhook 监控,大媒体库(500T 以上)可以不开 cd2 永久缓存,可实时监控。
配置指南
警告
webhook 仅 cd2 会员生效。
Webhook 【图文】
添加 Webhook

修改 Webhook 配置

Sa Webhook 推荐配置

结束
添加 Webhook
在 cd2 网页设置中,找到 设置 → Webhook → 添加 Webhook,下边的
webhook.toml进去。webhook.toml
# global variables: global variables are used to replace the placeholders in URL and body of the webhook # {device_name} - The name of the device # {user_name} - Current user name # {version} - The version of the application # {event_category} - The category of the event # {event_name} - The name of the event # {event_time} - The time of the event occurred, unix epoch time in seconds # {send_time} - The time of the data sent, unix epoch time in seconds # global parameters [global_params] # The base URL of the server to send the data to, the server must be able to receive POST requests base_url = "http://localhost:8095" # Whether the webhook is enabled enabled = true # The default http headers [global_params.default_headers] content-type = "application/json" user-agent = "clouddrive2/{version}" authorization = "basic usernamepassword" # File system watcher webhook configuration [file_system_watcher] # The URL of the server to send the data to, the server must be able to receive POST requests url = "{base_url}/api/v1/webhook/clouddrive2/file_notify?device_name={device_name}&user_name={user_name}&type={event_name}" # http method, can be "GET" or "POST", if not specified, the default value is POST method = "POST" # Whether the file system watcher is enabled enabled = true # The body to be sent to the server can be a JSON string # The following is a sample template for the data to be sent # the json string should contains at least an array of file changes, each file change item shoud contain the following fields # {event_category} - The category of the event is "file" # {event_name} - The name of the event is "notify" # {action} - The action of file change (create, delete, rename) # {is_dir} - Whether the file is a directory (false: file, true: directory) # {source_file} - The source file's path of the action # {destination_file} - The destination file's path of the action, only valid for action rename(move) body = ''' { "device_name": "{device_name}", "user_name": "{user_name}", "version": "{version}", "event_category": "{event_category}", "event_name": "{event_name}", "event_time": "{event_time}", "send_time": "{send_time}", "data": [ { "action": "{action}", "is_dir": "{is_dir}", "source_file": "{source_file}", "destination_file": "{destination_file}" } ] } ''' # specify additional http headers for the file system watcher request if required, headers with same name will override in the default headers [file_system_watcher.headers] additional_header = "value" # mount point watcher configuration [mount_point_watcher] # The URL of the server to send the data to, the server must be able to receive POST requests url = "{base_url}/api/v1/webhook/clouddrive2/mount_notify?device_name={device_name}&user_name={user_name}&type={event_name}" # http method method = "POST" # Whether the mount point watcher is enabled enabled = true # The body to be sent to the server can be a JSON string # The following is a sample template for the data to be sent # the mount_point_watcher should contains at least an array of mount point changes, each mount point change item shoud contain the following fields # {event_category} - The category of the event is "mount_point" # {event_name} - The name of the event is "mount" or "unmount" # {action} - The action of mount point change (mount, unmount) # {mount_point} - The mount point's path of the action # {status} - The status of the action (true for success, false for failed) # {reason} - The failed reason, empty string means success body = ''' { "device_name": "{device_name}", "user_name": "{user_name}", "version": "{version}", "event_category": "{event_category}", "event_name": "{event_name}", "event_time": "{event_time}", "send_time": "{send_time}", "data": [ { "action": "{action}", "mount_point": "{mount_point}", "status": "{status}", "reason": "{reason}" } ] } ''' # specify additional http headers for the file system watcher request if required, headers with same name will override in the default headers [mount_point_watcher.headers] user-agent = "clouddrive2/{version}/mount"修改 Webhook 配置
- 将
base_url = "http://localhost:8095"修改为 Sa 实际的 IP 地址。 - 改完记得重启 cd2,使 webhook 生效。
- 将
Sa Webhook 推荐配置
直接看下边图文的 第 ③ 步 吧。
结束