Method: files.watch
HTTP 请求
POST https://www.googleapis.com/drive/v3/files/{fileId}/watch
网址采用 gRPC 转码语法。
查询参数
参数 |
supportsAllDrives |
boolean
发出请求的应用是否同时支持“我的云端硬盘”和共享云端硬盘。
|
supportsTeamDrives (deprecated) |
boolean
已弃用:请改用 supportsAllDrives 。
|
acknowledgeAbuse |
boolean
用户是否已确认下载已知恶意软件或其他存在滥用行为的文件的风险。只有当 alt 参数设为 media 且用户是文件的所有者或文件所在共享云端硬盘的组织者时,这种情况才适用。
|
includePermissionsForView |
string
指定要在响应中包含的其他视图权限。仅“已发布”。
|
includeLabels |
string
要在响应的 labelInfo 部分包含的标签 ID 列表(以英文逗号分隔)。
|
请求正文
请求正文包含一个 Channel
实例。
响应正文
如果成功,则响应正文包含一个 Channel
实例。
授权范围
需要以下 OAuth 范围之一:
https://www.googleapis.com/auth/drive
https://www.googleapis.com/auth/drive.appdata
https://www.googleapis.com/auth/drive.file
https://www.googleapis.com/auth/drive.meet.readonly
https://www.googleapis.com/auth/drive.metadata
https://www.googleapis.com/auth/drive.metadata.readonly
https://www.googleapis.com/auth/drive.photos.readonly
https://www.googleapis.com/auth/drive.readonly
部分范围受到限制,需要对应用进行安全评估才能使用。有关详情,请参阅授权指南。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2024-09-03。
[null,null,["最后更新时间 (UTC):2024-09-03。"],[[["Subscribes to changes to a file using the `POST https://www.googleapis.com/drive/v3/files/{fileId}/watch` endpoint, where `{fileId}` represents the ID of the file."],["Request body and successful response body both contain an instance of [Channel](/drive/api/reference/rest/v3/channels#Channel), enabling subscription to file changes."],["Accepts various query parameters like `supportsAllDrives`, `acknowledgeAbuse`, `includePermissionsForView`, and `includeLabels` to customize the subscription request."],["Requires authorization with one of the listed OAuth scopes, such as `https://www.googleapis.com/auth/drive` or `https://www.googleapis.com/auth/drive.file`, to access and subscribe to file changes."]]],["This outlines how to subscribe to file changes using a `POST` request to `https://www.googleapis.com/drive/v3/files/{fileId}/watch`. Key actions include setting the `fileId` in the path and using query parameters like `supportsAllDrives`, `acknowledgeAbuse`, `includePermissionsForView`, and `includeLabels`. The request and response bodies both use a `Channel` instance. The request requires specific authorization scopes, such as `drive`, `drive.file`, or `drive.readonly`. Some scopes have restrictions.\n"]]