添付ファイル
非推奨。このクラスは非推奨のため、新しいスクリプトでは使用しないでください。
ページに添付する Google サイトの添付ファイル。
Attachment は blob であり、blob 入力が必要な場所であればどこでも使用できます。
var filesPage = SitesApp.getSite('example.com', 'mysite').getChildByName("files");
var attachments = filesPage.getAttachments();
// DocsList.createFile accepts a blob input. Since an Attachment is just a blob, we can
// just pass it directly to that method
var file = DocsList.createFile(attachments[0]);
getAttachmentType()
非推奨。この関数は非推奨のため、新しいスクリプトでは使用しないでください。
この添付ファイルのタイプ(HOSTED または WEB)を返します。
var pages = SitesApp.getSite('example.com', 'mysite').getChildren();
var attachments = pages[0].getAttachments();
var attType = attachments[0].getAttachmentType();
// This will log "Hosted"
Logger.log(attType);
// Since this returns an AttachmentType and not a String, for the
// purposes of equivalence we want to either do this or cast the
// type to a String
if(attType == SitesService.AttachmentType.HOSTED) {
Logger.log("This is a match");
}
// The above is the same as
if(String(attType) == "Hosted") {
Logger.log("This is also a match");
}
戻る
AttachmentType
- アタッチメントの種類
承認
このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。
-
https://sites.google.com/feeds
getContentType()
非推奨。この関数は非推奨のため、新しいスクリプトでは使用しないでください。
この添付ファイルの MIME タイプを返します。ウェブ添付ファイルの場合は失敗します。
var pages = SitesApp.getSite('example.com', 'mysite').getChildren();
var attachments = pages[0].getAttachments();
var contentType = attachments[0].getContentType();
戻る
String
- 添付ファイルの MIME タイプ
承認
このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。
-
https://sites.google.com/feeds
getDatePublished()
非推奨。この関数は非推奨のため、新しいスクリプトでは使用しないでください。
この添付ファイルが最初に公開された日付を返します。
var pages = SitesApp.getSite('example.com', 'mysite').getChildren();
var attachments = pages[0].getAttachments();
var date = attachments[0].getDatePublished();
戻る
Date
- 最初の公開日
承認
このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。
-
https://sites.google.com/feeds
getUrl()
非推奨。この関数は非推奨のため、新しいスクリプトでは使用しないでください。
この添付ファイルのダウンロード URL を返します。
var pages = SitesApp.getSite('example.com', 'mysite').getChildren();
var attachments = pages[0].getAttachments();
var url = attachments[0].getUrl();
戻る
String
- ダウンロード URL
承認
このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。
-
https://sites.google.com/feeds
setContentType(contentType)
非推奨。この関数は非推奨のため、新しいスクリプトでは使用しないでください。
このアタッチメントの MIME タイプを設定します。ウェブ添付ファイルの場合は失敗します。
var pages = SitesApp.getSite('example.com', 'mysite').getChildren();
var attachments = pages[0].getAttachments();
attachments[0].setContentType("text/plain");
パラメータ
名前 | 型 | 説明 |
contentType | String | 新しい MIME タイプ |
戻る
Attachment
- チェーン用のこのアタッチメント
承認
このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。
-
https://sites.google.com/feeds
setDescription(description)
非推奨。この関数は非推奨のため、新しいスクリプトでは使用しないでください。
この添付ファイルの説明を設定します。
var pages = SitesApp.getSite('example.com', 'mysite').getChildren();
var attachments = pages[0].getAttachments();
// This is an example of chaining in action
attachments[0].setTitle("New Title")
.setDescription("New Description");
パラメータ
名前 | 型 | 説明 |
description | String | 新しい説明文 |
戻る
Attachment
- チェーン用のこのアタッチメント
承認
このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。
-
https://sites.google.com/feeds
setFrom(blob)
非推奨。この関数は非推奨のため、新しいスクリプトでは使用しないでください。
このアタッチメントの実際のデータを設定します。ウェブ添付ファイルの場合は失敗します。
var pages = SitesApp.getSite('demositeappsscript').getChildren();
var attachments = pages[0].getAttachments();
// This snippet demonstrates how to create a new text blob and attach it
// to the page
var blob = Utilities.newBlob("This data is now the attachment content");
// We must set a filename since we created the blob from String data
// instead of something like a URL source
blob.setName("attachment.txt");
attachments[0].setTitle("New Title")
.setDescription("New Description")
.setContentType("text/plain")
.setFrom(blob);
パラメータ
戻る
Attachment
- チェーン用のこのアタッチメント
承認
このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。
-
https://sites.google.com/feeds
setParent(parent)
非推奨。この関数は非推奨のため、新しいスクリプトでは使用しないでください。
この添付ファイルの親ページを設定します。
var pages = SitesApp.getSite('example.com', 'mysite').getChildren();
var attachments = pages[0].getAttachments();
// Sets the parent page to be the next sibling
attachments[0].setParent(pages[1]);
パラメータ
戻る
Attachment
- チェーン用のこのアタッチメント
承認
このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。
-
https://sites.google.com/feeds
setTitle(title)
非推奨。この関数は非推奨のため、新しいスクリプトでは使用しないでください。
この添付ファイルのタイトルを設定します。
var pages = SitesApp.getSite('example.com', 'mysite').getChildren();
var attachments = pages[0].getAttachments();
// This is an example of chaining in action
attachments[0].setTitle("New Title")
.setDescription("New Description");
パラメータ
戻る
Attachment
- チェーン用のこのアタッチメント
承認
このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。
-
https://sites.google.com/feeds
setUrl(url)
非推奨。この関数は非推奨のため、新しいスクリプトでは使用しないでください。
この添付ファイルのダウンロード URL を設定します。ウェブ添付ファイルでのみ有効です。
var pages = SitesApp.getSite('demositeappsscript').getChildren();
var attachments = pages[0].getAttachments();
attachments[0].setTitle("New Web Attachment")
.setDescription("New Description")
.setUrl("http://example.com/files/your_file.txt");
パラメータ
戻る
Attachment
- チェーン用のこのアタッチメント
承認
このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。
-
https://sites.google.com/feeds