Class Attachment

附件

已弃用。此类已弃用,不应该用于新脚本。

网站附件,例如某页面附加的文件。

请注意,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]);

方法

方法返回类型简介
getAs(contentType)Blob返回此对象中的数据作为转换为指定内容类型的 blob。
getBlob()Blob返回此对象内的数据作为 blob。

详细文档

getAs(contentType)

返回此对象中的数据作为转换为指定内容类型的 blob。此方法会为文件名添加适当的扩展名,例如“myfile.pdf”。不过,系统会假定文件名中最后一个句点后面的部分(如果有)是应替换的现有扩展名。因此,“ShoppingList.12.25.2014”会变成“ShoppingList.12.25.pdf”。

如需查看转化次数的每日配额,请参阅 Google 服务的配额。新创建的 Google Workspace 网域可能会暂时受更严格的配额限制。

参数

名称类型说明
contentTypeString要转换为的 MIME 类型。对于大多数 blob,'application/pdf' 是唯一有效的选项。对于 BMP、GIF、JPEG 或 PNG 格式的图片,'image/bmp''image/gif''image/jpeg''image/png' 中的任意一个也有效。

返程

Blob - 作为 blob 的数据。


getBlob()

返回此对象内的数据作为 blob。

返程

Blob - 作为 blob 的数据。

已废弃的方法