Google ドライブ内のファイルに関連付けられているユーザー。ユーザーは File.getEditors()
、Folder.getViewers()
などのメソッドからアクセスできます。
// Log the email address of all users who have edit access to a file. var file = DriveApp.getFileById('1234567890abcdefghijklmnopqrstuvwxyz'); var editors = file.getEditors(); for (var i = 0; i < editors.length; i++) { Logger.log(editors[i].getEmail()); }
Methods
方法 | 戻り値の型 | 概要 |
---|---|---|
getDomain() | String | ユーザーのアカウントに関連付けられたドメイン名を取得します。 |
getEmail() | String | ユーザーのメールアドレスを取得します。 |
getName() | String | ユーザー名を取得します。 |
getPhotoUrl() | String | ユーザーの写真の URL を取得します。 |
詳細なドキュメント
getDomain()
ユーザーのアカウントに関連付けられたドメイン名を取得します。
// Log the domain names associated with all users who have edit access to a file. var file = DriveApp.getFileById('1234567890abcdefghijklmnopqrstuvwxyz'); var editors = file.getEditors(); for (var i = 0; i < editors.length; i++) { Logger.log(editors[i].getDomain()); }
戻る
String
- ユーザーのアカウントに関連付けられているドメイン名
getEmail()
ユーザーのメールアドレスを取得します。ユーザーのメールアドレスは、ユーザーが Google+ アカウント設定ページでアドレスを共有することを選択した場合、またはユーザーがスクリプトを実行しているユーザーと同じドメインに属していて、ドメイン管理者がドメイン内のすべてのユーザーに他のユーザーのメールアドレスを表示することを許可している場合にのみ使用できます。
// Log the email address of all users who have edit access to a file. var file = DriveApp.getFileById('1234567890abcdefghijklmnopqrstuvwxyz'); var editors = file.getEditors(); for (var i = 0; i < editors.length; i++) { Logger.log(editors[i].getEmail()); }
戻る
String
- ユーザーのメールアドレス、またはメールアドレスが使用できない場合は空白の文字列。
getName()
ユーザー名を取得します。ユーザー名が利用できない場合、このメソッドは null
を返します。
// Log the names of all users who have edit access to a file. var file = DriveApp.getFileById('1234567890abcdefghijklmnopqrstuvwxyz'); var editors = file.getEditors(); for (var i = 0; i < editors.length; i++) { Logger.log(editors[i].getName()); }
戻る
String
- ユーザー、または名前が不明な場合は null
。
getPhotoUrl()
ユーザーの写真の URL を取得します。ユーザーの写真が利用できない場合、このメソッドは null
を返します。
// Log the URLs for the photos of all users who have edit access to a file. var file = DriveApp.getFileById('1234567890abcdefghijklmnopqrstuvwxyz'); var editors = file.getEditors(); for (var i = 0; i < editors.length; i++) { Logger.log(editors[i].getPhotoUrl()); }
戻る
String
- ユーザーの写真の URL。写真を取得できない場合は null
。