Method: permissions.create
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
สร้างสิทธิ์สำหรับไฟล์หรือไดรฟ์ที่แชร์
คำเตือน: ระบบไม่รองรับการดำเนินการเกี่ยวกับสิทธิ์พร้อมกันในไฟล์เดียวกัน โดยจะใช้เฉพาะการอัปเดตล่าสุดเท่านั้น
คำขอ HTTP
POST https://www.googleapis.com/drive/v3/files/{fileId}/permissions
URL ใช้ไวยากรณ์การแปลงรหัส gRPC
พารามิเตอร์เส้นทาง
พารามิเตอร์ |
fileId |
string
รหัสของไฟล์หรือไดรฟ์ที่แชร์
|
พารามิเตอร์การค้นหา
พารามิเตอร์ |
emailMessage |
string
ข้อความที่กำหนดเองแบบข้อความธรรมดาที่จะรวมไว้ในอีเมลแจ้งเตือน
|
enforceSingleParent (deprecated) |
boolean
เลิกใช้งานแล้ว: ดูรายละเอียดได้ที่ moveToNewOwnersRoot
|
moveToNewOwnersRoot |
boolean
พารามิเตอร์นี้จะมีผลก็ต่อเมื่อรายการไม่ได้อยู่ในไดรฟ์ที่แชร์และคำขอพยายามโอนการเป็นเจ้าของรายการ หากตั้งค่าเป็น true ระบบจะย้ายรายการไปยังโฟลเดอร์รูทของไดรฟ์ของฉันของเจ้าของใหม่และนำโฟลเดอร์ระดับบนก่อนหน้าทั้งหมดออก หากตั้งค่าเป็น false ระบบจะไม่เปลี่ยนแปลงผู้ปกครอง
|
sendNotificationEmail |
boolean
เลือกว่าจะส่งอีเมลแจ้งเตือนเมื่อแชร์กับผู้ใช้หรือกลุ่มหรือไม่ โดยค่าเริ่มต้น ระบบจะตั้งค่าเป็น true สำหรับผู้ใช้และกลุ่ม และไม่อนุญาตสำหรับคำขออื่นๆ โดยจะต้องไม่ปิดใช้สำหรับการโอนความเป็นเจ้าของ
|
supportsAllDrives |
boolean
แอปพลิเคชันที่ขอรองรับทั้งไดรฟ์ของฉันและไดรฟ์ที่แชร์หรือไม่
|
supportsTeamDrives (deprecated) |
boolean
เลิกใช้งานแล้ว: โปรดใช้ supportsAllDrives แทน
|
transferOwnership |
boolean
จะโอนความเป็นเจ้าของไปยังผู้ใช้ที่ระบุและดาวน์เกรดเจ้าของปัจจุบันเป็นผู้เขียนหรือไม่ ต้องระบุพารามิเตอร์นี้เพื่อเป็นการรับทราบผลข้างเคียง
|
useDomainAdminAccess |
boolean
ส่งคำขอในฐานะผู้ดูแลระบบโดเมน หากตั้งค่าเป็นจริง ผู้ขอจะได้รับสิทธิ์เข้าถึงหากพารามิเตอร์รหัสไฟล์อ้างอิงถึงไดรฟ์ที่แชร์ และผู้ขอเป็นผู้ดูแลระบบของโดเมนที่ไดรฟ์ที่แชร์เป็นของโดเมนนั้น
|
enforceExpansiveAccess |
boolean
คำขอควรบังคับใช้กฎการเข้าถึงแบบขยายหรือไม่
|
เนื้อความของคำขอ
เนื้อความของคำขอมีอินสแตนซ์ของ Permission
เนื้อหาการตอบกลับ
หากทำสำเร็จ เนื้อหาการตอบกลับจะมีอินสแตนซ์ Permission
ที่สร้างขึ้นใหม่
ขอบเขตการให้สิทธิ์
ต้องใช้ขอบเขต OAuth อย่างใดอย่างหนึ่งต่อไปนี้
https://www.googleapis.com/auth/drive
https://www.googleapis.com/auth/drive.file
ขอบเขตบางอย่างถูกจำกัดและต้องมีการประเมินความปลอดภัยเพื่อให้แอปของคุณใช้ขอบเขตเหล่านั้นได้ ดูข้อมูลเพิ่มเติมได้ที่คู่มือการให้สิทธิ์
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-08-27 UTC
[null,null,["อัปเดตล่าสุด 2025-08-27 UTC"],[],[],null,["# Method: permissions.create\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\nCreates 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/v3/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 of the file or shared drive. |\n\n### Query parameters\n\n| Parameters ||\n|----------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `emailMessage` | `string` A plain text custom message to include in the notification email. |\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| `sendNotificationEmail` | `boolean` Whether to send a notification email when sharing to users or groups. This defaults to true for users and groups, and is not allowed for other requests. It must not be disabled for ownership transfers. |\n| `supportsAllDrives` | `boolean` Whether the requesting application supports both My Drives and shared drives. |\n| `supportsTeamDrives` **(deprecated)** | `boolean` Deprecated: Use `supportsAllDrives` instead. |\n| `transferOwnership` | `boolean` Whether to transfer ownership to the specified user and downgrade the current owner to a writer. This parameter is required as an acknowledgement of the side effect. |\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/v3/permissions#Permission).\n\n### Response body\n\nIf successful, the response body contains a newly created instance of [Permission](/workspace/drive/api/reference/rest/v3/permissions#Permission).\n\n### Authorization scopes\n\nRequires one of the following OAuth scopes:\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)."]]