Enum Access
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
存取權
這個列舉代表可存取檔案或資料夾的使用者類別,除了明確授予存取權的個別使用者之外。您可以透過 DriveApp.Access
存取這些屬性。
如要呼叫列舉,請呼叫其父項類別、名稱和屬性。例如
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);
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-07-26 (世界標準時間)。
[null,null,["上次更新時間:2025-07-26 (世界標準時間)。"],[[["\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. |"]]