Google ドライブ内のファイル。ファイルは Drive からアクセスまたは作成できます。
// Trash every untitled spreadsheet that hasn't been updated in a week. const files = DriveApp.getFilesByName('Untitled spreadsheet'); while (files.hasNext()) { const file = files.next(); if (new Date() - file.getLastUpdated() > 7 * 24 * 60 * 60 * 1000) { file.setTrashed(true); } }
メソッド
| メソッド | 戻り値の型 | 概要 |
|---|---|---|
add | File | 指定されたユーザーを File のコメント投稿者のリストに追加します。 |
add | File | 指定されたユーザーを File のコメント投稿者のリストに追加します。 |
add | File | 指定されたユーザーの配列を File のコメント投稿者のリストに追加します。 |
add | File | 指定されたユーザーを File の編集者のリストに追加します。 |
add | File | 指定されたユーザーを File の編集者のリストに追加します。 |
add | File | 指定されたユーザーの配列を File の編集者のリストに追加します。 |
add | File | 指定されたユーザーを File の閲覧者リストに追加します。 |
add | File | 指定されたユーザーを File の閲覧者リストに追加します。 |
add | File | 指定されたユーザーの配列を File の視聴者リストに追加します。 |
get | Permission | 特定のユーザーに付与された権限を取得します。 |
get | Permission | 特定のユーザーに付与された権限を取得します。 |
get | Blob | このオブジェクト内のデータを、指定されたコンテンツ タイプに変換された blob として返します。 |
get | Blob | このオブジェクト内のデータを blob として返します。 |
get | Date | File が作成された日付を取得します。 |
get | String | File の説明を取得します。 |
get | String | ファイルのダウンロードに使用できる URL を取得します。 |
get | User[] | この File の編集者のリストを取得します。 |
get | String | File の ID を取得します。 |
get | Date | File が最後に更新された日付を取得します。 |
get | String | ファイルの MIME タイプを取得します。 |
get | String | File の名前を取得します。 |
get | User | ファイルのオーナーを取得します。 |
get | Folder | File の直近の親であるフォルダのコレクションを取得します。 |
get | String | リンクを使用して共有されたアイテムにアクセスするために必要な File のリソースキーを取得します。 |
get | Boolean | この File が、リンクを使用して共有されたときにアクセスにリソースキーを必要とするセキュリティ アップデートを適用できるかどうかを取得します。 |
get | Boolean | この File がリンクを使用して共有されるときに、アクセスにリソースキーが必要かどうかを取得します。 |
get | Access | 明示的にアクセス権が付与された個々のユーザーを除き、どのクラスのユーザーが File にアクセスできるかを取得します。 |
get | Permission | File にアクセスできるユーザーに付与された権限を取得します。明示的にアクセス権が付与された個々のユーザーは除きます。 |
get | Integer | ドライブに File を保存するために使用されるバイト数を取得します。 |
get | String | これがショートカットの場合、指しているアイテムの ID を返します。 |
get | String | これがショートカットの場合、参照先のアイテムの MIME タイプを返します。 |
get | String | ファイルがショートカットの場合、そのショートカットが指すアイテムのリソースキーを返します。 |
get | Blob|null | ファイルのサムネイル画像を取得します。サムネイルが存在しない場合は null を返します。 |
get | String | ドライブやドキュメントなどの Google アプリで File を開くために使用できる URL を取得します。 |
get | User[] | この File の閲覧者とコメント投稿者のリストを取得します。 |
is | Boolean | File の編集権限を持つユーザーが、他のユーザーと共有したり、権限を変更したりできるかどうかを指定します。 |
is | Boolean | File がユーザーのドライブでスター付きになっているかどうかを判断します。 |
is | Boolean | File がユーザーのドライブのゴミ箱にあるかどうかを判断します。 |
make | File | ファイルのコピーを作成します。 |
make | File | 移動先のディレクトリにファイルのコピーを作成します。 |
make | File | ファイルのコピーを作成し、指定された名前を付けます。 |
make | File | 宛先ディレクトリにファイルのコピーを作成し、指定された名前を付けます。 |
move | File | このアイテムを指定された移動先フォルダに移動します。 |
remove | File | 指定されたユーザーを File のコメント投稿者リストから削除します。 |
remove | File | 指定されたユーザーを File のコメント投稿者リストから削除します。 |
remove | File | 指定されたユーザーを File の編集者リストから削除します。 |
remove | File | 指定されたユーザーを File の編集者リストから削除します。 |
remove | File | 指定されたユーザーを File の閲覧者とコメント投稿者のリストから削除します。 |
remove | File | 指定されたユーザーを File の閲覧者とコメント投稿者のリストから削除します。 |
revoke | File | 指定されたユーザーに付与された File へのアクセス権を取り消します。 |
revoke | File | 指定されたユーザーに付与された File へのアクセス権を取り消します。 |
set | File | ファイルの内容を指定された置換で上書きします。 |
set | File | File の説明を設定します。 |
set | File | File の名前を設定します。 |
set | File | File のオーナーを変更します。 |
set | File | File のオーナーを変更します。 |
set | File | リンクを使用して共有するときに、File がアクセスにリソースキーを必要とするかどうかを設定します。 |
set | File | File の編集権限を持つユーザーが他のユーザーと共有したり、権限を変更したりすることを許可するかどうかを設定します。 |
set | File | File にアクセスできるユーザーのクラスと、明示的にアクセス権が付与された個々のユーザーに加えて、それらのユーザーに付与される権限を設定します。 |
set | File | ユーザーのドライブで File にスターを付けるかどうかを設定します。 |
set | File | File がユーザーのドライブのゴミ箱にあるかどうかを設定します。 |
詳細なドキュメント
add Commenter(emailAddress)
指定されたユーザーを File のコメント投稿者のリストに追加します。ユーザーが視聴者リストにすでに登録されている場合、このメソッドはユーザーを視聴者リストから削除します。
const files = DriveApp.getFilesByName('Test'); // Loops through the files while (files.hasNext()) { const file = files.next(); file.addCommenter('hello@example.com'); }
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
email | String | 追加するユーザーのメールアドレス。 |
戻る
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/drive
add Commenter(user)
指定されたユーザーを File のコメント投稿者のリストに追加します。ユーザーが視聴者リストにすでに登録されている場合、このメソッドはユーザーを視聴者リストから削除します。
// Gets a list of all files in Google Drive with the given name. // TODO(developer): Replace the file name with your own. const files = DriveApp.getFilesByName('Test'); // Adds the active user as a commenter. while (files.hasNext()) { const file = files.next(); file.addCommenter(Session.getActiveUser()); }
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
user | User | 追加するユーザーの表現。 |
戻る
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/drive
add Commenters(emailAddresses)
指定されたユーザーの配列を File のコメント投稿者のリストに追加します。ユーザーが視聴者リストにすでに含まれている場合、このメソッドは視聴者リストからそのユーザーを削除します。
// Gets a list of all files in Google Drive with the given name. // TODO(developer): Replace the file name with your own. const files = DriveApp.getFilesByName('Test'); while (files.hasNext()) { const file = files.next(); // TODO(developer): Replace 'cloudysanfrancisco@gmail.com' and // 'baklavainthebalkans@gmail.com' with the email addresses to add as // commenters. const emails = [ 'cloudysanfrancisco@gmail.com', 'baklavainthebalkans@gmail.com', ]; console.log(file.addCommenters(emails)); }
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
email | String[] | 追加するユーザーのメールアドレスの配列。 |
戻る
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/drive
add Editor(emailAddress)
add Editor(user)
add Editors(emailAddresses)
add Viewer(emailAddress)
add Viewer(user)
add Viewers(emailAddresses)
get Access(email)
特定のユーザーに付与された権限を取得します。このメソッドは、Google グループの権限や、Google グループを通じて継承された権限を返すことをサポートしていません。
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
email | String | 権限を確認するユーザーのメールアドレス。Google グループはサポートされていません。 |
戻る
Permission - ユーザーに付与された権限。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/drive.readonly -
https://www.googleapis.com/auth/drive
get Access(user)
特定のユーザーに付与された権限を取得します。このメソッドは、Google グループの権限や、Google グループを通じて継承された権限を返すことをサポートしていません。
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
user | User | 権限を確認するユーザーの表現。 |
戻る
Permission - ユーザーに付与された権限。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/drive.readonly -
https://www.googleapis.com/auth/drive
get As(contentType)
このオブジェクト内のデータを、指定されたコンテンツ タイプに変換された blob として返します。このメソッドは、ファイル名に適切な拡張子(例: 「myfile.pdf」)を追加します。ただし、最後のピリオドの後に続くファイル名の一部(存在する場合)は、置き換える必要がある既存の拡張子であると想定されます。その結果、「ShoppingList.12.25.2014」は「ShoppingList.12.25.pdf」になります。
コンバージョンの 1 日あたりの割り当てを確認するには、Google サービスの割り当てをご覧ください。新しく作成された Google Workspace ドメインには、一時的に厳しい割り当てが適用されることがあります。
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
content | String | 変換先の MIME タイプ。ほとんどの BLOB では、'application/pdf' が唯一の有効なオプションです。BMP、GIF、JPEG、PNG 形式の画像の場合、'image/bmp'、'image/gif'、'image/jpeg'、'image/png' のいずれも有効です。Google ドキュメントの場合、'text/markdown' も有効です。 |
戻る
Blob - blob としてのデータ。
get Blob()
get Date Created()
get Description()
get Download Url()
ファイルのダウンロードに使用できる URL を取得します。Google ドライブでファイルを開く権限を持つユーザーのみが URL にアクセスできます。この URL はブラウザでファイル ダウンロードに使用できますが、Url でファイルを取得するために使用することはできません。スクリプトでファイルの内容が必要な場合は、get を使用します。
// Gets a list of all files in Google Drive with the given name. // TODO(developer): Replace the file name with your own. const files = DriveApp.getFilesByName('Test'); // Loops through the files and logs the download URLs to the console. while (files.hasNext()) { const file = files.next(); console.log(file.getDownloadUrl()); }
戻る
String - ファイルのダウンロードに使用できる URL。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/drive.readonly -
https://www.googleapis.com/auth/drive
get Editors()
この File の編集者のリストを取得します。スクリプトを実行するユーザーに File の編集権限がない場合、このメソッドは空の配列を返します。
// Gets a list of all files in Google Drive with the given name. // TODO(developer): Replace the file name with your own. const files = DriveApp.getFilesByName('Test'); // Loops through the files. while (files.hasNext()) { const file = files.next(); // Adds the email addresses in the array as editors of each file. // TODO(developer): Replace 'cloudysanfrancisco@gmail.com' // and 'baklavainthebalkans@gmail.com' with valid email addresses. file.addEditors([ 'cloudysanfrancisco@gmail.com', 'baklavainthebalkans@gmail.com', ]); // Gets a list of the file editors. const editors = file.getEditors(); // For each file, logs the editors' email addresses to the console. for (const editor of editors) { console.log(editor.getEmail()); } }
戻る
User[] - ユーザーがこの File の編集権限を持っている場合、編集者のリストを返します。ユーザーに編集権限がない場合は、空の配列を返します。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/drive.readonly -
https://www.googleapis.com/auth/drive
get Id()
get Last Updated()
get Mime Type()
ファイルの MIME タイプを取得します。
// Gets a list of all files in Google Drive with the given name. // TODO(developer): Replace the file name with your own. const files = DriveApp.getFilesByName('Test'); // Loops through the files and logs the MIME type to the console. while (files.hasNext()) { const file = files.next(); console.log(file.getMimeType()); }
戻る
String - ファイルの MIME タイプ。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/drive.readonly -
https://www.googleapis.com/auth/drive
get Name()
get Owner()
ファイルのオーナーを取得します。
// Gets a list of all files in Google Drive with the given name. // TODO(developer): Replace the file name with your own. const files = DriveApp.getFilesByName('Test'); // Loops through the files and logs the names of the file owners to the console. while (files.hasNext()) { const file = files.next(); console.log(file.getOwner().getName()); }
戻る
User - ファイルのオーナー。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/drive.readonly -
https://www.googleapis.com/auth/drive
get Parents()
File の直近の親であるフォルダのコレクションを取得します。
戻る
Folder - File の直近の親であるフォルダのコレクション
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/drive.readonly -
https://www.googleapis.com/auth/drive
get Resource Key()
get Security Update Eligible()
この File が、リンクを使用して共有されたときにアクセスにリソースキーを必要とするセキュリティ アップデートを適用できるかどうかを取得します。
リンクを使用して共有された一部のファイルやフォルダにアクセスするには、ドライブでリソースキーが必要です。この変更は、セキュリティ アップデートの一部です。この更新は、対象となるファイルとフォルダに対してデフォルトで有効になっています。対象となるファイルのリソースキー要件をオンまたはオフにするには、set を使用します。
詳しくは、Google ドライブのセキュリティ アップデートをご覧ください。
戻る
Boolean - リソースキーの要件を File に適用できるかどうか。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/drive.readonly -
https://www.googleapis.com/auth/drive
get Security Update Enabled()
この File がリンクを使用して共有されるときに、アクセスにリソースキーが必要かどうかを取得します。この要件は、対象となるファイルとフォルダに対してデフォルトで有効になっています。対象となるファイルのリソースキー要件をオンまたはオフにするには、
setSecurityUpdateEnabled を使用します。
詳しくは、Google ドライブのセキュリティ アップデートをご覧ください。
戻る
Boolean - この File でリソースキーの要件が有効かどうか。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/drive.readonly -
https://www.googleapis.com/auth/drive
get Sharing Access()
get Sharing Permission()
File にアクセスできるユーザーに付与された権限を取得します。明示的にアクセス権が付与された個々のユーザーは除きます。
戻る
Permission - File にアクセスできるユーザーに付与される権限
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/drive.readonly -
https://www.googleapis.com/auth/drive
get Size()
get Target Id()
これがショートカットの場合、指しているアイテムの ID を返します。
それ以外の場合は null を返します。
// The ID of the file for which to make a shortcut and the ID of // the folder to which you want to add the shortcut. // TODO(developer): Replace the file and folder IDs with your IDs. const fileId = 'abc123456'; const folderId = 'xyz987654'; // Gets the folder to add the shortcut to. const folder = DriveApp.getFolderById(folderId); // Creates a shortcut of the file and moves it to the specified folder. const shortcut = DriveApp.createShortcut(fileId).moveTo(folder); // Logs the target ID of the shortcut. console.log(`${shortcut.getName()}=${shortcut.getTargetId()}`);
戻る
String - ターゲット アイテムの ID。
get Target Mime Type()
これがショートカットの場合、参照先のアイテムの MIME タイプを返します。
それ以外の場合は null を返します。
// The ID of the file for which to make a shortcut and the ID of // the folder to which you want to add the shortcut. // TODO(developer): Replace the file and folder IDs with your IDs. const fileId = 'abc123456'; const folderId = 'xyz987654'; // Gets the folder to add the shortcut to. const folder = DriveApp.getFolderById(folderId); // Creates a shortcut of the file and moves it to the specified folder. const shortcut = DriveApp.createShortcut(fileId).moveTo(folder); // Logs the MIME type of the file that the shortcut points to. console.log(`MIME type of the shortcut: ${shortcut.getTargetMimeType()}`);
戻る
String - ターゲット アイテムの MIME タイプ。
get Target Resource Key()
ファイルがショートカットの場合、そのファイルが指すアイテムのリソースキーを返します。リソースキーは、リンクを使用して共有されたファイルにアクセスするために渡す必要がある追加のパラメータです。
ファイルがショートカットでない場合は、null を返します。
// Gets a file by its ID. // TODO(developer): Replace 'abc123456' with your file ID. const file = DriveApp.getFileById('abc123456'); // If the file is a shortcut, returns the resource key of the file that it // points to. console.log(file.getTargetResourceKey());
戻る
String - ターゲット アイテムのリソースキー。ファイルがショートカットでない場合は null。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/drive.readonly -
https://www.googleapis.com/auth/drive
get Thumbnail()
ファイルのサムネイル画像を取得します。サムネイルが存在しない場合は null を返します。
// Gets a list of all files in Google Drive with the given name. // TODO(developer): Replace the file name with your own. const files = DriveApp.getFilesByName('Test'); // Loops through the files. while (files.hasNext()) { const file = files.next(); // Logs the thumbnail image for each file to the console as a blob, // or null if no thumbnail exists. console.log(file.getThumbnail()); }
戻る
Blob|null - ファイルのサムネイル画像。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/drive.readonly -
https://www.googleapis.com/auth/drive
get Url()
get Viewers()
この File の閲覧者とコメント投稿者のリストを取得します。スクリプトを実行するユーザーに File の編集権限がない場合、このメソッドは空の配列を返します。
// Gets a list of all files in Google Drive with the given name. // TODO(developer): Replace the file name with your own. const files = DriveApp.getFilesByName('Test'); // Loops through the files. while (files.hasNext()) { const file = files.next(); // For each file, logs the viewers' email addresses to the console. const viewers = file.getViewers(); for (const viewer of viewers) { console.log(viewer.getEmail()); } }
戻る
User[] - ユーザーがこの File の編集権限を持っている場合、閲覧者とコメント投稿者のリストを返します。ユーザーに編集権限がない場合は、空の配列を返します。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/drive.readonly -
https://www.googleapis.com/auth/drive
is Starred()
is Trashed()
make Copy()
ファイルのコピーを作成します。
// Gets a list of all files in Google Drive with the given name. // TODO(developer): Replace the file name with your own. const files = DriveApp.getFilesByName('Test'); // Loops through the files. while (files.hasNext()) { const file = files.next(); // Creates a copy of each file and logs the file name to the console. console.log(file.makeCopy().getName()); }
戻る
File - 新しいコピー。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/drive
make Copy(destination)
宛先ディレクトリにファイルのコピーを作成します。
// Gets a list of all files in Google Drive with the given name. // TODO(developer): Replace the file name with your own. const files = DriveApp.getFilesByName('Test'); // Loops through the files. while (files.hasNext()) { const file = files.next(); // Creates a copy of each file and adds it to the specified folder. // TODO(developer): Replace the folder ID with your own. const destination = DriveApp.getFolderById('123456abcxyz'); const copiedFile = file.makeCopy(destination); // Logs the file names to the console. console.log(copiedFile.getName()); }
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
destination | Folder | ファイルのコピー先のディレクトリ。 |
戻る
File - 新しいコピー。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/drive
make Copy(name)
ファイルのコピーを作成し、指定された名前を付けます。
// Gets a list of all files in Google Drive with the given name. // TODO(developer): Replace the file name with your own. const files = DriveApp.getFilesByName('Test'); // Loops through the files. while (files.hasNext()) { const file = files.next(); // Creates a copy of each file and sets the name to 'Test-Copy.' const filename = file.makeCopy('Test-Copy'); // Logs the copied file's name to the console. console.log(filename.getName()); }
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
name | String | 新しいコピーに適用するファイル名。 |
戻る
File - 新しいコピー。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/drive
make Copy(name, destination)
宛先ディレクトリにファイルのコピーを作成し、指定された名前を付けます。
// Gets a list of all files in Google Drive with the given name. // TODO(developer): Replace the file name with your own. const files = DriveApp.getFilesByName('Test'); // Loops through the files. while (files.hasNext()) { const file = files.next(); // Creates a copy of each file, sets the file name, and adds the copied file // to the specified folder. // TODO(developer): Replace the folder ID with your own. const destination = DriveApp.getFolderById('123456abcxyz'); const copiedFile = file.makeCopy('Test-Copy', destination); // Logs the file names to the console. console.log(copiedFile.getName()); }
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
name | String | 新しいコピーに適用するファイル名。 |
destination | Folder | ファイルのコピー先のディレクトリ。 |
戻る
File - 新しいコピー。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/drive
move To(destination)
remove Commenter(emailAddress)
指定されたユーザーを File のコメント投稿者リストから削除します。このメソッドは、ユーザーが一般アクセス権を持つユーザーのクラスに属している場合(たとえば、File がユーザーのドメイン全体と共有されている場合など)に、ユーザーが File にアクセスすることをブロックしません。
// Gets a list of all files in Google Drive with the given name. // TODO(developer): Replace the file name with your own. const files = DriveApp.getFilesByName('Test'); // Loops through the files. while (files.hasNext()) { const file = files.next(); // Removes the given user from the list of commenters for each file. // TODO(developer): Replace the email with the email of the user you want to // remove. file.removeCommenter('cloudysanfrancisco@gmail.com'); }
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
email | String | 削除するユーザーのメールアドレス。 |
戻る
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/drive
remove Commenter(user)
指定されたユーザーを File のコメント投稿者リストから削除します。このメソッドは、ユーザーが一般アクセス権を持つユーザーのクラスに属している場合(たとえば、File がユーザーのドメイン全体と共有されている場合など)に、ユーザーが File にアクセスすることをブロックしません。
// Gets a list of all files in Google Drive with the given name. // TODO(developer): Replace the file name with your own. const files = DriveApp.getFilesByName('Test'); // Loops through the files. while (files.hasNext()) { const file = files.next(); // Removes the given user from the list of commenters for each file. console.log(file.removeCommenter(Session.getActiveUser())); }
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
user | User | 削除するユーザーの表現。 |
戻る
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/drive
remove Editor(emailAddress)
指定されたユーザーを File の編集者リストから削除します。この方法では、ユーザーが一般的なアクセス権を持つユーザーのクラスに属している場合(たとえば、File がユーザーのドメイン全体と共有されている場合や、File がユーザーがアクセスできる共有ドライブにある場合など)、ユーザーが File にアクセスすることをブロックしません。
ドライブ ファイルの場合、この操作を行うと、閲覧者リストからもユーザーが削除されます。
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
email | String | 削除するユーザーのメールアドレス。 |
戻る
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/drive
remove Editor(user)
指定されたユーザーを File の編集者リストから削除します。この方法では、ユーザーが一般的なアクセス権を持つユーザーのクラスに属している場合(たとえば、File がユーザーのドメイン全体と共有されている場合や、File がユーザーがアクセスできる共有ドライブにある場合など)、ユーザーが File にアクセスすることをブロックしません。
ドライブ ファイルの場合、この操作を行うと、閲覧者リストからもユーザーが削除されます。
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
user | User | 削除するユーザーの表現。 |
戻る
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/drive
remove Viewer(emailAddress)
指定されたユーザーを File の閲覧者とコメント投稿者のリストから削除します。ユーザーが閲覧者やコメント投稿者ではなく編集者の場合、このメソッドは無効です。また、この方法では、ユーザーが一般アクセス権を持つユーザーのクラスに属している場合(たとえば、File がユーザーのドメイン全体と共有されている場合や、File がユーザーがアクセスできる共有ドライブにある場合など)、ユーザーが File にアクセスすることをブロックしません。
ドライブ ファイルの場合、この操作を行うと、ユーザーは編集者のリストからも削除されます。
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
email | String | 削除するユーザーのメールアドレス。 |
戻る
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/drive
remove Viewer(user)
指定されたユーザーを File の閲覧者とコメント投稿者のリストから削除します。ユーザーが閲覧者ではなく編集者の場合、このメソッドは効果がありません。また、この方法では、一般アクセス権を持つユーザーのクラスに属しているユーザーが File にアクセスすることをブロックできません。たとえば、File がユーザーのドメイン全体と共有されている場合や、File がユーザーがアクセスできる共有ドライブにある場合などです。
ドライブ ファイルの場合、この操作を行うと、ユーザーは編集者のリストからも削除されます。
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
user | User | 削除するユーザーの表現。 |
戻る
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/drive
revoke Permissions(emailAddress)
revoke Permissions(user)
set Content(content)
ファイルの内容を指定された置換で上書きします。content が 10 MB を超える場合は例外をスローします。
// Creates a text file with the content 'Hello, world!' const file = DriveApp.createFile('New Text File', 'Hello, world!'); // Logs the content of the text file to the console. console.log(file.getBlob().getDataAsString()); // Updates the content of the text file to 'Updated text!' file.setContent('Updated text!'); // Logs content of the text file to the console. console.log(file.getBlob().getDataAsString());
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
content | String | ファイルの新しいコンテンツ。 |
戻る
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/drive
set Description(description)
set Name(name)
set Owner(emailAddress)
set Owner(user)
set Security Update Enabled(enabled)
set Sharing(accessType, permissionType)
File にアクセスできるユーザーのクラスと、明示的にアクセス権が付与された個々のユーザーに加えて、それらのユーザーに付与される権限を設定します。
// 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);
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
access | Access | どのクラスのユーザーが File にアクセスできるようにするか |
permission | Permission | File にアクセスできるユーザーに付与する必要がある権限 |
戻る
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/drive