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 | ユーザーの写真の URL を取得します。 |
詳細なドキュメント
getDomain()
ユーザーのアカウントに関連付けられたドメイン名を取得します。
// 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 - ユーザーのアカウントに関連付けられたドメイン名
getEmail()
ユーザーのメールアドレスを取得します。ユーザーのメールアドレスは、ユーザーが 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 - ユーザーのメールアドレス。メールアドレスが利用できない場合は空の文字列
getName()
ユーザーの名前を取得します。ユーザーの名前が利用できない場合、このメソッドは 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
getPhotoUrl()
ユーザーの写真の 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 - ユーザーの写真の URL。写真が利用できない場合は null