附件
已淘汰。這個類別已淘汰,不應用於新的指令碼。
協作平台附件,例如附加至網頁的檔案。
請注意,附件是 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
:附件類型
授權
使用這個方法的指令碼必須取得以下一或多個範圍的授權:
-
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 類型
授權
使用這個方法的指令碼必須取得以下一或多個範圍的授權:
-
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
— 這個鏈結附件
授權
使用這個方法的指令碼必須取得以下一或多個範圍的授權:
-
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
— 這個鏈結附件
授權
使用這個方法的指令碼必須取得以下一或多個範圍的授權:
-
https://sites.google.com/feeds