Enum MimeType
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
MIME 类型
一个枚举,用于提供对 MIME 类型声明的访问,而无需明确输入字符串。预期 MIME 类型以字符串(例如
'image/png'
)呈现的方法也接受以下任一值,前提是该方法支持底层 MIME 类型。
// Use MimeType enum to log the name of every Google Doc in the user's Drive.
const docs = DriveApp.getFilesByType(MimeType.GOOGLE_DOCS);
while (docs.hasNext()) {
const doc = docs.next();
Logger.log(doc.getName());
}
// Use plain string to log the size of every PNG in the user's Drive.
const pngs = DriveApp.getFilesByType('image/png');
while (pngs.hasNext()) {
const png = pngs.next();
Logger.log(png.getSize());
}
属性
属性 | 类型 | 说明 |
GOOGLE_APPS_SCRIPT | Enum | Google Apps 脚本项目的 MIME 类型表示法。 |
GOOGLE_DRAWINGS | Enum | Google 绘图文件的 MIME 类型表示法。 |
GOOGLE_DOCS | Enum | Google 文档文件的 MIME 类型表示法。 |
GOOGLE_FORMS | Enum | Google 表单文件的 MIME 类型表示法。 |
GOOGLE_SHEETS | Enum | Google 表格文件的 MIME 类型表示法。 |
GOOGLE_SITES | Enum | Google 协作平台文件的 MIME 类型表示法。 |
GOOGLE_SLIDES | Enum | Google 幻灯片文件的 MIME 类型表示法。 |
FOLDER | Enum | Google 云端硬盘文件夹的 MIME 类型表示法。 |
SHORTCUT | Enum | Google 云端硬盘快捷方式的 MIME 类型表示法。 |
BMP | Enum | BMP 图片文件(通常为 .bmp)的 MIME 类型表示法。 |
GIF | Enum | GIF 图片文件(通常为 .gif)的 MIME 类型表示法。 |
JPEG | Enum | JPEG 图片文件(通常为 .jpg)的 MIME 类型表示法。 |
PNG | Enum | PNG 图片文件的 MIME 类型表示法(通常为 .png)。 |
SVG | Enum | SVG 图片文件(通常为 .svg)的 MIME 类型表示法。 |
PDF | Enum | PDF 文件的 MIME 类型表示(通常为 .pdf)。 |
CSS | Enum | CSS 文本文件(通常为 .css)的 MIME 类型表示法。 |
CSV | Enum | CSV 文本文件(通常为 .csv)的 MIME 类型表示法。 |
HTML | Enum | HTML 文本文件(通常为 .html)的 MIME 类型表示法。 |
JAVASCRIPT | Enum | JavaScript 文本文件(通常为 .js)的 MIME 类型表示法。 |
PLAIN_TEXT | Enum | 纯文本文件(通常为 .txt)的 MIME 类型表示法。 |
RTF | Enum | 富文本文件(通常为 .rtf)的 MIME 类型表示法。 |
OPENDOCUMENT_GRAPHICS | Enum | OpenDocument 图形文件(通常为 .odg)的 MIME 类型表示法。 |
OPENDOCUMENT_PRESENTATION | Enum | OpenDocument 演示文稿文件(通常为 .odp)的 MIME 类型表示法。 |
OPENDOCUMENT_SPREADSHEET | Enum | OpenDocument 电子表格文件(通常为 .ods)的 MIME 类型表示法。 |
OPENDOCUMENT_TEXT | Enum | OpenDocument 文档处理文件(通常为 .odt)的 MIME 类型表示法。 |
MICROSOFT_EXCEL | Enum | Microsoft Excel 电子表格文件(通常为 .xlsx)的 MIME 类型表示法。 |
MICROSOFT_EXCEL_LEGACY | Enum | Microsoft Excel 旧版文件(通常为 .xls)的 MIME 类型表示法。 |
MICROSOFT_POWERPOINT | Enum | Microsoft PowerPoint 演示文稿文件(通常为 .pptx)的 MIME 类型表示法。 |
MICROSOFT_POWERPOINT_LEGACY | Enum | Microsoft PowerPoint 旧版文件(通常为 .ppt)的 MIME 类型表示法。 |
MICROSOFT_WORD | Enum | Microsoft Word 文档文件(通常为 .docx)的 MIME 类型表示法。 |
MICROSOFT_WORD_LEGACY | Enum | Microsoft Word 旧版文件(通常为 .doc)的 MIME 类型表示法。 |
ZIP | Enum | ZIP 归档文件(通常为 .zip)的 MIME 类型表示法。 |
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-26。
[null,null,["最后更新时间 (UTC):2025-07-26。"],[[["\u003cp\u003e\u003ccode\u003eMimeType\u003c/code\u003e is an enumeration providing access to MIME-type declarations without manually typing strings, offering a more convenient way to specify file types in Apps Script.\u003c/p\u003e\n"],["\u003cp\u003eMethods accepting MIME types as strings (e.g., \u003ccode\u003e'image/png'\u003c/code\u003e) also accept \u003ccode\u003eMimeType\u003c/code\u003e enum values if the underlying MIME type is supported.\u003c/p\u003e\n"],["\u003cp\u003eThis enumeration covers a wide range of file types, including Google Workspace files, common image and document formats, and Microsoft Office file types.\u003c/p\u003e\n"],["\u003cp\u003eRefer to the provided property table for a comprehensive list of supported MIME types and their corresponding \u003ccode\u003eMimeType\u003c/code\u003e enum values.\u003c/p\u003e\n"]]],[],null,["# Enum MimeType\n\nMimeType\n\nAn enumeration that provides access to MIME-type declarations without typing the strings\nexplicitly. Methods that expect a MIME type rendered as a string (for example, `\n'image/png'`) also accept any of the values below, so long as the method supports the\nunderlying MIME type.\n\n```javascript\n// Use MimeType enum to log the name of every Google Doc in the user's Drive.\nconst docs = DriveApp.getFilesByType(MimeType.GOOGLE_DOCS);\nwhile (docs.hasNext()) {\n const doc = docs.next();\n Logger.log(doc.getName());\n}\n\n// Use plain string to log the size of every PNG in the user's Drive.\nconst pngs = DriveApp.getFilesByType('image/png');\nwhile (pngs.hasNext()) {\n const png = pngs.next();\n Logger.log(png.getSize());\n}\n``` \n\n### Properties\n\n| Property | Type | Description |\n|-------------------------------|--------|---------------------------------------------------------------------------------------------|\n| `GOOGLE_APPS_SCRIPT` | `Enum` | Representation of MIME type for a Google Apps Script project. |\n| `GOOGLE_DRAWINGS` | `Enum` | Representation of MIME type for a Google Drawings file. |\n| `GOOGLE_DOCS` | `Enum` | Representation of MIME type for a Google Docs file. |\n| `GOOGLE_FORMS` | `Enum` | Representation of MIME type for a Google Forms file. |\n| `GOOGLE_SHEETS` | `Enum` | Representation of MIME type for a Google Sheets file. |\n| `GOOGLE_SITES` | `Enum` | Representation of MIME type for a Google Sites file. |\n| `GOOGLE_SLIDES` | `Enum` | Representation of MIME type for a Google Slides file. |\n| `FOLDER` | `Enum` | Representation of MIME type for a Google Drive folder. |\n| `SHORTCUT` | `Enum` | Representation of MIME type for a Google Drive shortcut. |\n| `BMP` | `Enum` | Representation of MIME type for a BMP image file (typically .bmp). |\n| `GIF` | `Enum` | Representation of MIME type for a GIF image file (typically .gif). |\n| `JPEG` | `Enum` | Representation of MIME type for a JPEG image file (typically .jpg). |\n| `PNG` | `Enum` | Representation of MIME type for a PNG image file (typically .png). |\n| `SVG` | `Enum` | Representation of MIME type for an SVG image file (typically .svg). |\n| `PDF` | `Enum` | Representation of MIME type for a PDF file (typically .pdf). |\n| `CSS` | `Enum` | Representation of MIME type for a CSS text file (typically .css). |\n| `CSV` | `Enum` | Representation of MIME type for a CSV text file (typically .csv). |\n| `HTML` | `Enum` | Representation of MIME type for an HTML text file (typically .html). |\n| `JAVASCRIPT` | `Enum` | Representation of MIME type for a JavaScript text file (typically .js). |\n| `PLAIN_TEXT` | `Enum` | Representation of MIME type for a plain text file (typically .txt). |\n| `RTF` | `Enum` | Representation of MIME type for a rich text file (typically .rtf). |\n| `OPENDOCUMENT_GRAPHICS` | `Enum` | Representation of MIME type for an OpenDocument graphics file (typically .odg). |\n| `OPENDOCUMENT_PRESENTATION` | `Enum` | Representation of MIME type for an OpenDocument presentation file (typically .odp). |\n| `OPENDOCUMENT_SPREADSHEET` | `Enum` | Representation of MIME type for an OpenDocument spreadsheet file (typically .ods). |\n| `OPENDOCUMENT_TEXT` | `Enum` | Representation of MIME type for an OpenDocument word-processing file (typically .odt). |\n| `MICROSOFT_EXCEL` | `Enum` | Representation of MIME type for a Microsoft Excel spreadsheet file (typically .xlsx). |\n| `MICROSOFT_EXCEL_LEGACY` | `Enum` | Representation of MIME type for a Microsoft Excel legacy file (typically .xls). |\n| `MICROSOFT_POWERPOINT` | `Enum` | Representation of MIME type for a Microsoft PowerPoint presentation file (typically .pptx). |\n| `MICROSOFT_POWERPOINT_LEGACY` | `Enum` | Representation of MIME type for a Microsoft PowerPoint legacy file (typically .ppt). |\n| `MICROSOFT_WORD` | `Enum` | Representation of MIME type for a Microsoft Word document file (typically .docx). |\n| `MICROSOFT_WORD_LEGACY` | `Enum` | Representation of MIME type for a Microsoft Word legacy file (typically .doc). |\n| `ZIP` | `Enum` | Representation of MIME type for a ZIP archive file (typically .zip). |"]]