与 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