Enum Access
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 truy cập
Một enum đại diện cho các lớp 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.Access
.
Để 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.Access.ANYONE
.
// Creates a folder that anyone on the Internet can read from and write to.
// (Domain administrators can prohibit this setting for users of a Google
// Workspace domain.)
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ả |
ANYONE | Enum | Bất kỳ ai trên Internet đều có thể tìm và truy cập. Bạn không cần đăng nhập.
Quản trị viên miền có thể cấm người dùng miền Google Workspace sử dụng chế độ cài đặt này. Nếu bạn tắt chế độ cài đặt này, việc truyền giá trị này đến File.setSharing(accessType, permissionType) sẽ gửi một ngoại lệ.
|
ANYONE_WITH_LINK | Enum | Bất kỳ ai có đường liên kết đều có thể truy cập. Bạn không cần đăng nhập.
Quản trị viên miền có thể cấm người dùng miền Google Workspace sử dụng chế độ cài đặt này. Nếu bạn tắt chế độ cài đặt này, việc truyền giá trị này đến File.setSharing(accessType, permissionType) sẽ gửi một ngoại lệ.
|
DOMAIN | Enum | Những người trong miền của bạn có thể tìm và truy cập. Yêu cầu đăng nhập.
Chế độ cài đặt này chỉ dành cho người dùng miền Google Workspace. Đối với các loại Tài khoản Google khác, việc truyền giá trị này đến File.setSharing(accessType, permissionType) sẽ gửi một ngoại lệ.
|
DOMAIN_WITH_LINK | Enum | Những người trong miền của bạn có đường liên kết đều có thể truy cập. Yêu cầu đăng nhập.
Chế độ cài đặt này chỉ dành cho người dùng miền Google Workspace. Đối với các loại Tài khoản Google khác, việc truyền giá trị này đến File.setSharing(accessType, permissionType) sẽ gửi một ngoại lệ.
|
PRIVATE | Enum | Chỉ những người được cấp quyền rõ ràng mới có thể truy cập. Yêu cầu đăng nhập. |
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.Access\u003c/code\u003e is an enum used to define user access levels for files and folders in Google Drive, beyond individual permissions.\u003c/p\u003e\n"],["\u003cp\u003eYou can set file or folder sharing permissions using methods like \u003ccode\u003esetSharing()\u003c/code\u003e along with the \u003ccode\u003eDriveApp.Access\u003c/code\u003e and \u003ccode\u003eDriveApp.Permission\u003c/code\u003e enums.\u003c/p\u003e\n"],["\u003cp\u003eSeveral access levels are available: \u003ccode\u003eANYONE\u003c/code\u003e, \u003ccode\u003eANYONE_WITH_LINK\u003c/code\u003e, \u003ccode\u003eDOMAIN\u003c/code\u003e, \u003ccode\u003eDOMAIN_WITH_LINK\u003c/code\u003e, and \u003ccode\u003ePRIVATE\u003c/code\u003e, each controlling who can access the content.\u003c/p\u003e\n"],["\u003cp\u003eDomain administrators in Google Workspace can restrict the use of \u003ccode\u003eANYONE\u003c/code\u003e and \u003ccode\u003eANYONE_WITH_LINK\u003c/code\u003e sharing options for their users.\u003c/p\u003e\n"]]],[],null,["# Enum Access\n\nAccess\n\nAn enum representing classes of users who can access a file or folder, besides any individual\nusers who have been explicitly given access. These properties can be accessed from [DriveApp.Access](/apps-script/reference/drive/drive-app#Access).\n\nTo call an enum, you call its parent class, name, and property. For example, `\nDriveApp.Access.ANYONE`.\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 users of a Google\n// Workspace domain.)\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| `ANYONE` | `Enum` | Anyone on the Internet can find and access. No sign-in required. Domain administrators can prohibit this setting for users of a Google Workspace domain. If the setting is disabled, passing this value to [File.setSharing(accessType, permissionType)](/apps-script/reference/drive/file#setSharing(Access,Permission)) throws an exception. |\n| `ANYONE_WITH_LINK` | `Enum` | Anyone who has the link can access. No sign-in required. Domain administrators can prohibit this setting for users of a Google Workspace domain. If the setting is disabled, passing this value to [File.setSharing(accessType, permissionType)](/apps-script/reference/drive/file#setSharing(Access,Permission)) throws an exception. |\n| `DOMAIN` | `Enum` | People in your domain can find and access. Sign-in required. This setting is available only for users of a Google Workspace domain. For other types of Google accounts, passing this value to [File.setSharing(accessType, permissionType)](/apps-script/reference/drive/file#setSharing(Access,Permission)) throws an exception. |\n| `DOMAIN_WITH_LINK` | `Enum` | People in your domain who have the link can access. Sign-in required. This setting is available only for users of a Google Workspace domain. For other types of Google accounts, passing this value to [File.setSharing(accessType, permissionType)](/apps-script/reference/drive/file#setSharing(Access,Permission)) throws an exception. |\n| `PRIVATE` | `Enum` | Only people explicitly granted permission can access. Sign-in required. |"]]