與 Google 雲端硬碟檔案相關聯的使用者。使用者可透過 File.getEditors()、Folder.getViewers() 和其他方法存取。
// Log the email address of all users who have edit access to a file. const file = DriveApp.getFileById('1234567890abcdefghijklmnopqrstuvwxyz'); const editors = file.getEditors(); for (let i = 0; i < editors.length; i++) { Logger.log(editors[i].getEmail()); }
方法
| 方法 | 傳回類型 | 簡短說明 |
|---|---|---|
get | String|null | 取得與使用者帳戶相關聯的網域名稱。 |
get | String|null | 取得使用者的電子郵件地址。 |
get | String|null | 取得使用者名稱。 |
get | String|null | 取得使用者相片的網址。 |
內容詳盡的說明文件
get Domain()
取得與使用者帳戶相關聯的網域名稱。
// Log the domain names associated with all users who have edit access to a // file. const file = DriveApp.getFileById('1234567890abcdefghijklmnopqrstuvwxyz'); const editors = file.getEditors(); for (let i = 0; i < editors.length; i++) { Logger.log(editors[i].getDomain()); }
回攻員
String|null:與使用者帳戶相關聯的網域名稱
get Email()
取得使用者的電子郵件地址。只有在使用者選擇從 Google+ 帳戶設定頁面分享電子郵件地址,或使用者與執行指令碼的使用者屬於相同網域,且網域管理員允許網域內所有使用者查看其他使用者的電子郵件地址時,才能取得使用者的電子郵件地址。
// Log the email address of all users who have edit access to a file. const file = DriveApp.getFileById('1234567890abcdefghijklmnopqrstuvwxyz'); const editors = file.getEditors(); for (let i = 0; i < editors.length; i++) { Logger.log(editors[i].getEmail()); }
回攻員
String|null:使用者的電子郵件地址,如果沒有電子郵件地址,則為空白字串
get Name()
取得使用者名稱。如果使用者名稱無法使用,這個方法會傳回 null。
// Log the names of all users who have edit access to a file. const file = DriveApp.getFileById('1234567890abcdefghijklmnopqrstuvwxyz'); const editors = file.getEditors(); for (let i = 0; i < editors.length; i++) { Logger.log(editors[i].getName()); }
回攻員
String|null:使用者名稱,或 null (如果沒有名稱)
get Photo Url()
取得使用者相片的網址。如果無法取得使用者的相片,這個方法會傳回 null。
// Log the URLs for the photos of all users who have edit access to a file. const file = DriveApp.getFileById('1234567890abcdefghijklmnopqrstuvwxyz'); const editors = file.getEditors(); for (let i = 0; i < editors.length; i++) { Logger.log(editors[i].getPhotoUrl()); }
回攻員
String|null:使用者相片的網址,或 null (如果沒有相片)