Enum Permission
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.
Quyền
Một enum đại diện cho các quyền được cấp cho người dùng có thể truy cập vào một tệp hoặc thư mục, ngoài bất kỳ người dùng cá nhân nào đã được cấp quyền truy cập một cách rõ ràng. Bạn có thể truy cập vào các thuộc tính này từ DriveApp.Permission
.
Để gọi một enum, bạn gọi lớp mẹ, tên và thuộc tính của enum đó. Ví dụ:
DriveApp.Permission.VIEW
.
// Creates a folder that anyone on the Internet can read from and write to.
// (Domain administrators can prohibit this setting for Google Workspace users.)
const folder = DriveApp.createFolder('Shared Folder');
folder.setSharing(DriveApp.Access.ANYONE, DriveApp.Permission.EDIT);
Thuộc tính
Thuộc tính | Loại | Mô tả |
VIEW | Enum | Những người dùng có thể truy cập vào tệp hoặc thư mục chỉ có thể xem hoặc sao chép tệp/thư mục đó. Việc truyền giá trị này vào File.setSharing(accessType, permissionType) sẽ gửi một ngoại lệ nếu loại tệp không hỗ trợ giá trị này. |
EDIT | Enum | Những người dùng có thể truy cập vào tệp hoặc thư mục sẽ có thể chỉnh sửa tệp hoặc thư mục đó. Trừ phi bạn đặt File.setShareableByEditors(shareable) thành false , người dùng cũng có thể thay đổi chế độ cài đặt chia sẻ. Việc truyền giá trị này đến File.setSharing(accessType, permissionType) sẽ gửi một ngoại lệ nếu loại tệp không hỗ trợ giá trị này. |
COMMENT | Enum | Những người dùng có thể truy cập vào tệp hoặc thư mục chỉ có thể xem, sao chép hoặc nhận xét về tệp hoặc thư mục đó.
Việc truyền giá trị này đến File.setSharing(accessType, permissionType) sẽ gửi một ngoại lệ nếu loại tệp không hỗ trợ giá trị đó. |
OWNER | Enum | Người dùng sở hữu tệp hoặc thư mục đó. Bạn có thể trả về giá trị này, nhưng việc truyền giá trị này đến File.setSharing(accessType, permissionType) sẽ gửi một ngoại lệ. |
ORGANIZER | Enum | Người dùng có thể sắp xếp tệp và thư mục trong bộ nhớ dùng chung. Bạn có thể trả về giá trị này, nhưng việc truyền giá trị này đến File.setSharing(accessType, permissionType) sẽ gửi một ngoại lệ. |
FILE_ORGANIZER | Enum | Những người dùng có thể chỉnh sửa, chuyển vào thùng rác và di chuyển nội dung trong bộ nhớ dùng chung. Bạn có thể trả về giá trị này, nhưng việc truyền giá trị này đến File.setSharing(accessType, permissionType) sẽ gửi một ngoại lệ. |
NONE | Enum | Người dùng không có quyền đối với tệp hoặc thư mục. Bạn có thể trả về giá trị này, nhưng việc truyền giá trị này đến File.setSharing(accessType, permissionType) sẽ gửi một ngoại lệ, trừ phi bạn đặt giá trị này kết hợp với Access.ANYONE . |
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-07-26 UTC.
[null,null,["Cập nhật lần gần đây nhất: 2025-07-26 UTC."],[[["\u003cp\u003e\u003ccode\u003eDriveApp.Permission\u003c/code\u003e is an enum that represents the permissions granted to users for accessing files or folders, in addition to individually assigned permissions.\u003c/p\u003e\n"],["\u003cp\u003eYou can use \u003ccode\u003eDriveApp.Permission\u003c/code\u003e properties like \u003ccode\u003eVIEW\u003c/code\u003e, \u003ccode\u003eEDIT\u003c/code\u003e, \u003ccode\u003eCOMMENT\u003c/code\u003e, etc. to define access levels when setting sharing settings for files or folders.\u003c/p\u003e\n"],["\u003cp\u003eCalling an enum property involves using the parent class, name, and property, such as \u003ccode\u003eDriveApp.Permission.VIEW\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eWhile some properties like \u003ccode\u003eOWNER\u003c/code\u003e, \u003ccode\u003eORGANIZER\u003c/code\u003e, \u003ccode\u003eFILE_ORGANIZER\u003c/code\u003e, and \u003ccode\u003eNONE\u003c/code\u003e can be returned, they cannot be used to set sharing permissions and will throw an exception.\u003c/p\u003e\n"]]],["The `Permission` enum in DriveApp defines user access levels for files/folders. Key permissions include `VIEW` (view/copy), `EDIT` (edit, potentially share), and `COMMENT` (view, copy, comment). `OWNER`, `ORGANIZER`, and `FILE_ORGANIZER` are for ownership and shared drive organization. `NONE` indicates no permissions. `setSharing()` can define these permissions using `DriveApp.Permission.ENUM_NAME`, except for `OWNER`, `ORGANIZER`, `FILE_ORGANIZER`, and sometimes `NONE`. The `setSharing` method also accepts an `Access` type to define who these permissions apply to.\n"],null,["# Enum Permission\n\nPermission\n\nAn enum representing the permissions granted to users who can access a file or folder, besides\nany individual users who have been explicitly given access. These properties can be accessed from\n[DriveApp.Permission](/apps-script/reference/drive/drive-app#Permission).\n\nTo call an enum, you call its parent class, name, and property. For example, `\nDriveApp.Permission.VIEW`.\n\n```javascript\n// Creates a folder that anyone on the Internet can read from and write to.\n// (Domain administrators can prohibit this setting for Google Workspace users.)\nconst folder = DriveApp.createFolder('Shared Folder');\nfolder.setSharing(DriveApp.Access.ANYONE, DriveApp.Permission.EDIT);\n``` \n\n### Properties\n\n| Property | Type | Description |\n|------------------|--------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `VIEW` | `Enum` | Users who can access the file or folder are able only to view it or copy it. Passing this value to [File.setSharing(accessType, permissionType)](/apps-script/reference/drive/file#setSharing(Access,Permission)) throws an exception if the type of file does not support it. |\n| `EDIT` | `Enum` | Users who can access the file or folder are able to edit it. Unless [File.setShareableByEditors(shareable)](/apps-script/reference/drive/file#setShareableByEditors(Boolean)) is set to `false`, users can also change the sharing settings. Passing this value to [File.setSharing(accessType, permissionType)](/apps-script/reference/drive/file#setSharing(Access,Permission)) throws an exception if the type of file does not support it. |\n| `COMMENT` | `Enum` | Users who can access the file or folder are able only to view it, copy it, or comment on it. Passing this value to [File.setSharing(accessType, permissionType)](/apps-script/reference/drive/file#setSharing(Access,Permission)) throws an exception if the type of file does not support it. |\n| `OWNER` | `Enum` | The user owns the file or folder. This value can be returned, but passing it to [File.setSharing(accessType, permissionType)](/apps-script/reference/drive/file#setSharing(Access,Permission)) throws an exception. |\n| `ORGANIZER` | `Enum` | Users who can organize files and folders within a shared drive. This value can be returned, but passing it to [File.setSharing(accessType, permissionType)](/apps-script/reference/drive/file#setSharing(Access,Permission)) throws an exception. |\n| `FILE_ORGANIZER` | `Enum` | Users who can edit, trash, and move content within a shared drive. This value can be returned, but passing it to [File.setSharing(accessType, permissionType)](/apps-script/reference/drive/file#setSharing(Access,Permission)) throws an exception. |\n| `NONE` | `Enum` | The user does not have any permissions for the file or folder. This value can be returned, but passing it to [File.setSharing(accessType, permissionType)](/apps-script/reference/drive/file#setSharing(Access,Permission)) throws an exception unless it is set in combination with [Access.ANYONE](/apps-script/reference/drive/access#ANYONE). |"]]