Method: permissions.insert
插入文件或共享云端硬盘的权限。
警告:不支持对同一文件同时执行权限操作;系统只会应用上次更新时间。
HTTP 请求
POST https://www.googleapis.com/drive/v2/files/{fileId}/permissions
网址采用 gRPC 转码语法。
路径参数
参数 |
fileId |
string
文件或共享云端硬盘的 ID。
|
查询参数
参数 |
emailMessage |
string
要在通知电子邮件中包含的纯文本自定义消息。
|
enforceSingleParent (deprecated) |
boolean
已弃用:如需了解详情,请参阅 moveToNewOwnersRoot 。
|
moveToNewOwnersRoot |
boolean
只有当内容不在共享云端硬盘中,并且请求尝试转移该内容的所有权时,此参数才会生效。如果设为“true ”,这项内容将会移至新所有者的“我的云端硬盘”根文件夹,并且之前的所有父级文件夹都会被移除。如果设置为 false ,则父级不会更改。
|
sendNotificationEmails |
boolean
是否在与用户或群组共享时发送通知电子邮件。如果 role 为 owner ,此参数会被忽略,并且系统会发送电子邮件。
|
supportsAllDrives |
boolean
发出请求的应用是否同时支持“我的云端硬盘”和共享云端硬盘。
|
supportsTeamDrives (deprecated) |
boolean
已废弃:请改用 supportsAllDrives 。
|
useDomainAdminAccess |
boolean
以网域管理员的身份发出请求;如果设为 true,则当文件 ID 参数引用了共享云端硬盘,且请求者是共享云端硬盘所属网域的管理员时,请求者将获得访问权限。
|
请求正文
请求正文包含一个 Permission
实例。
响应正文
如果成功,响应正文将包含一个新创建的 Permission
实例。
授权范围
需要以下 OAuth 范围之一:
https://www.googleapis.com/auth/docs
https://www.googleapis.com/auth/drive
https://www.googleapis.com/auth/drive.file
某些范围受到限制,您的应用必须接受安全评估才能使用这些范围。有关详情,请参阅授权指南。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2024-09-03。
[null,null,["最后更新时间 (UTC):2024-09-03。"],[[["Inserts a permission for a file or shared drive, but concurrent operations on the same file aren't supported."],["Uses an HTTP POST request to `https://www.googleapis.com/drive/v2/files/{fileId}/permissions` to insert the permission."],["Requires providing `fileId` as a path parameter and allows optional query parameters like `emailMessage`, `moveToNewOwnersRoot`, and others for customization."],["The request body should contain a `Permission` object, and a successful response will return the newly created `Permission` object."],["Requires authorization with one of the following OAuth scopes: `https://www.googleapis.com/auth/docs`, `https://www.googleapis.com/auth/drive`, or `https://www.googleapis.com/auth/drive.file`."]]],["This document outlines the process of inserting a permission for a file or shared drive via a `POST` request to the Google Drive API. The request requires a `fileId` path parameter. Query parameters include options for email notifications (`sendNotificationEmails`, `emailMessage`), ownership transfer (`moveToNewOwnersRoot`), and shared drive support (`supportsAllDrives`). The request body contains permission details and successful requests return the created permission instance. Authentication requires specific OAuth scopes like `https://www.googleapis.com/auth/drive`. Concurrent permission changes are not supported.\n"]]