Method: permissions.insert
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
แทรกสิทธิ์สำหรับไฟล์หรือไดรฟ์ที่แชร์
คำเตือน: ระบบไม่รองรับการดำเนินการเกี่ยวกับสิทธิ์พร้อมกันในไฟล์เดียวกัน ระบบจะใช้เฉพาะการอัปเดตครั้งล่าสุดเท่านั้น
คำขอ HTTP
POST https://www.googleapis.com/drive/v2/files/{fileId}/permissions
URL ใช้ไวยากรณ์การแปลง gRPC
พารามิเตอร์เส้นทาง
พารามิเตอร์ |
fileId |
string
รหัสของไฟล์หรือไดรฟ์ที่แชร์
|
พารามิเตอร์การค้นหา
พารามิเตอร์ |
emailMessage |
string
ข้อความที่กำหนดเองที่เป็นข้อความธรรมดาเพื่อใส่ในอีเมลแจ้งเตือน
|
enforceSingleParent (deprecated) |
boolean
เลิกใช้งานแล้ว: ดูรายละเอียดได้ที่ moveToNewOwnersRoot
|
moveToNewOwnersRoot |
boolean
พารามิเตอร์นี้จะมีผลก็ต่อเมื่อรายการไม่ได้อยู่ในไดรฟ์ที่แชร์และคำขอพยายามโอนการเป็นเจ้าของรายการ หากตั้งค่าเป็น true ระบบจะย้ายรายการไปยังโฟลเดอร์รูทไดรฟ์ของฉันของเจ้าของใหม่และนำรายการหลักก่อนหน้าทั้งหมดออก หากตั้งค่าเป็น false ระบบจะไม่เปลี่ยนผู้ปกครอง
|
sendNotificationEmails |
boolean
ว่าจะส่งอีเมลแจ้งเตือนเมื่อแชร์กับผู้ใช้หรือกลุ่มหรือไม่ ระบบจะละเว้นพารามิเตอร์นี้และส่งอีเมลหาก role เป็น owner
|
supportsAllDrives |
boolean
แอปพลิเคชันที่ขอรองรับทั้งไดรฟ์ของฉันและไดรฟ์ที่แชร์หรือไม่
|
supportsTeamDrives (deprecated) |
boolean
เลิกใช้งานแล้ว: ให้ใช้ supportsAllDrives แทน
|
useDomainAdminAccess |
boolean
ส่งคำขอในฐานะผู้ดูแลระบบโดเมน หากตั้งค่าเป็น "จริง" ผู้ขอจะได้รับสิทธิ์เข้าถึงหากพารามิเตอร์รหัสไฟล์อ้างอิงถึงไดรฟ์ที่แชร์และผู้ขอเป็นผู้ดูแลระบบของโดเมนที่เป็นเจ้าของไดรฟ์ที่แชร์
|
enforceExpansiveAccess |
boolean
กำหนดว่าคำขอควรบังคับใช้กฎการเข้าถึงแบบขยายหรือไม่
|
เนื้อความของคำขอ
เนื้อความของคำขอมีอินสแตนซ์ของ 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 Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-25 UTC
[null,null,["อัปเดตล่าสุด 2025-07-25 UTC"],[],[],null,["# Method: permissions.insert\n\n- [HTTP request](#body.HTTP_TEMPLATE)\n- [Path parameters](#body.PATH_PARAMETERS)\n- [Query parameters](#body.QUERY_PARAMETERS)\n- [Request body](#body.request_body)\n- [Response body](#body.response_body)\n- [Authorization scopes](#body.aspect)\n- [Try it!](#try-it)\n\nInserts a permission for a file or shared drive.\n\n**Warning:** Concurrent permissions operations on the same file are not supported; only the last update is applied.\n\n### HTTP request\n\n`POST https://www.googleapis.com/drive/v2/files/{fileId}/permissions`\n\nThe URL uses [gRPC Transcoding](https://google.aip.dev/127) syntax.\n\n### Path parameters\n\n| Parameters ||\n|----------|-----------------------------------------------|\n| `fileId` | `string` The ID for the file or shared drive. |\n\n### Query parameters\n\n| Parameters ||\n|----------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `emailMessage` | `string` A plain text custom message to include in notification emails. |\n| `enforceSingleParent` **(deprecated)** | `boolean` Deprecated: See `moveToNewOwnersRoot` for details. |\n| `moveToNewOwnersRoot` | `boolean` This parameter will only take effect if the item is not in a shared drive and the request is attempting to transfer the ownership of the item. If set to `true`, the item will be moved to the new owner's My Drive root folder and all prior parents removed. If set to `false`, parents are not changed. |\n| `sendNotificationEmails` | `boolean` Whether to send notification emails when sharing to users or groups. This parameter is ignored and an email is sent if the `role` is `owner`. |\n| `supportsAllDrives` | `boolean` Whether the requesting application supports both My Drives and shared drives. |\n| `supportsTeamDrives` **(deprecated)** | `boolean` Deprecated: Use `supportsAllDrives` instead. |\n| `useDomainAdminAccess` | `boolean` Issue the request as a domain administrator; if set to true, then the requester will be granted access if the file ID parameter refers to a shared drive and the requester is an administrator of the domain to which the shared drive belongs. |\n| `enforceExpansiveAccess` | `boolean` Whether the request should enforce expansive access rules. |\n\n### Request body\n\nThe request body contains an instance of [Permission](/workspace/drive/api/reference/rest/v2/permissions#Permission).\n\n### Response body\n\nIf successful, the response body contains a newly created instance of [Permission](/workspace/drive/api/reference/rest/v2/permissions#Permission).\n\n### Authorization scopes\n\nRequires one of the following OAuth scopes:\n\n- `https://www.googleapis.com/auth/docs`\n- `\n https://www.googleapis.com/auth/drive`\n- `\n https://www.googleapis.com/auth/drive.file`\n\nSome scopes are restricted and require a security assessment for your app to use them. For more information, see the [Authorization guide](/workspace/guides/configure-oauth-consent)."]]