Method: permissions.create
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Tạo quyền cho một tệp hoặc bộ nhớ dùng chung.
Cảnh báo: Chúng tôi không hỗ trợ các thao tác cấp quyền đồng thời trên cùng một tệp; chỉ có nội dung cập nhật gần đây nhất được áp dụng.
Yêu cầu HTTP
POST https://www.googleapis.com/drive/v3/files/{fileId}/permissions
URL sử dụng cú pháp Chuyển mã gRPC.
Tham số đường dẫn
Thông số |
fileId |
string
Mã của tệp hoặc bộ nhớ dùng chung.
|
Tham số truy vấn
Thông số |
emailMessage |
string
Một thông báo tuỳ chỉnh bằng văn bản thuần tuý để đưa vào email thông báo.
|
enforceSingleParent (deprecated) |
boolean
Không dùng nữa: Hãy xem moveToNewOwnersRoot để biết thông tin chi tiết.
|
moveToNewOwnersRoot |
boolean
Tham số này sẽ chỉ có hiệu lực nếu mục không nằm trong bộ nhớ dùng chung và yêu cầu đang cố gắng chuyển quyền sở hữu mục. Nếu bạn đặt thành true , mục đó sẽ được di chuyển vào thư mục gốc Drive của tôi của chủ sở hữu mới và tất cả các thư mục mẹ trước đó sẽ bị xoá. Nếu bạn đặt thành false , thì cha mẹ sẽ không thay đổi.
|
sendNotificationEmail |
boolean
Có gửi email thông báo khi chia sẻ cho người dùng hoặc nhóm hay không. Giá trị mặc định là true đối với người dùng và nhóm, đồng thời không được phép đối với các yêu cầu khác. Bạn không được tắt chế độ này khi chuyển quyền sở hữu.
|
supportsAllDrives |
boolean
Liệu ứng dụng yêu cầu có hỗ trợ cả Drive của tôi và bộ nhớ dùng chung hay không.
|
supportsTeamDrives (deprecated) |
boolean
Không dùng nữa: Thay vào đó, hãy sử dụng supportsAllDrives .
|
transferOwnership |
boolean
Có chuyển quyền sở hữu cho người dùng được chỉ định và hạ cấp chủ sở hữu hiện tại xuống vai trò người viết hay không. Bạn phải cung cấp tham số này để xác nhận tác dụng phụ.
|
useDomainAdminAccess |
boolean
Đưa ra yêu cầu với tư cách là quản trị viên miền; nếu được đặt thành true, thì người yêu cầu sẽ được cấp quyền truy cập nếu tham số mã tệp đề cập đến một bộ nhớ dùng chung và người yêu cầu là quản trị viên của miền mà bộ nhớ dùng chung thuộc về.
|
enforceExpansiveAccess |
boolean
Yêu cầu có nên thực thi các quy tắc truy cập mở rộng hay không.
|
Nội dung yêu cầu
Nội dung yêu cầu chứa một bản sao của Permission
.
Nội dung phản hồi
Nếu thành công, nội dung phản hồi sẽ chứa một phiên bản mới được tạo của Permission
.
Phạm vi uỷ quyền
Yêu cầu một trong các phạm vi OAuth sau:
https://www.googleapis.com/auth/drive
https://www.googleapis.com/auth/drive.file
Một số phạm vi bị hạn chế và yêu cầu bạn phải đánh giá bảo mật để ứng dụng của bạn có thể sử dụng các phạm vi đó. Để biết thêm thông tin, hãy xem Hướng dẫn uỷ quyền.
Trừ phi có lưu ý khác, nội dung của trang này được cấp phép theo Giấy phép ghi nhận tác giả 4.0 của Creative Commons và các mẫu mã lập trình được cấp phép theo Giấy phép Apache 2.0. Để biết thông tin chi tiết, vui lòng tham khảo Chính sách trang web của Google Developers. Java là nhãn hiệu đã đăng ký của Oracle và/hoặc các đơn vị liên kết với Oracle.
Cập nhật lần gần đây nhất: 2025-08-27 UTC.
[null,null,["Cập nhật lần gần đây nhất: 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)."]]