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
部分範圍受到限制,應用程式必須進行安全性評估,才能使用這些範圍。詳情請參閱授權指南。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2024-09-03 (世界標準時間)。
[null,null,["上次更新時間: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"]]