Content Service
با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
محتوا
این سرویس به اسکریپت ها اجازه می دهد تا متن را به اشکال مختلف مانند متن، XML یا JSON ارائه دهند. همچنین به راهنمای خدمات محتوا مراجعه کنید. اگر اسکریپت زیر را به عنوان یک برنامه وب اجرا کنید ، "سلام، دنیا!" در مرورگر:
function doGet() {
return ContentService.createTextOutput('Hello, world!');
}
کلاس ها
نام | شرح مختصر |
---|
Content Service | سرویس برای برگرداندن محتوای متنی از یک اسکریپت. |
Mime Type | یک عدد برای انواع mime که می توان از یک اسکریپت ارائه کرد. |
Text Output | یک شی TextOutput که می تواند از یک اسکریپت ارائه شود. |
خواص
اموال | تایپ کنید | توضیحات |
---|
CSV | Enum | نوع Mime CSV |
ICAL | Enum | نوع Mime ICAL |
JAVASCRIPT | Enum | JAVASCRIPT نوع Mime |
JSON | Enum | JSON Mime Type |
TEXT | Enum | نوع Mime TEXT |
VCARD | Enum | نوع Mime VCARD |
جز در مواردی که غیر از این ذکر شده باشد،محتوای این صفحه تحت مجوز Creative Commons Attribution 4.0 License است. نمونه کدها نیز دارای مجوز Apache 2.0 License است. برای اطلاع از جزئیات، به خطمشیهای سایت Google Developers مراجعه کنید. جاوا علامت تجاری ثبتشده Oracle و/یا شرکتهای وابسته به آن است.
تاریخ آخرین بهروزرسانی 2025-07-24 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2025-07-24 بهوقت ساعت هماهنگ جهانی."],[[["\u003cp\u003eThe Content Service enables scripts to serve content like text, XML, or JSON, offering flexibility in data delivery.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can utilize the ContentService class to generate and manipulate text output within their scripts.\u003c/p\u003e\n"],["\u003cp\u003eMimeType aids in specifying the desired format for content delivery, accommodating various data types like CSV, JSON, and more.\u003c/p\u003e\n"],["\u003cp\u003eThe TextOutput class provides methods for managing the content, allowing for appending, clearing, and setting the output's format.\u003c/p\u003e\n"],["\u003cp\u003eContent served through scripts can be customized for display in browsers or downloaded as files, offering versatile content handling.\u003c/p\u003e\n"]]],[],null,["# Content Service\n\nContent\n\nThis service allows scripts to serve text in various forms, such as text,\nXML, or JSON. See also the [guide to\nContent Service](/apps-script/content_service). If you\n[deploy the following script as a web app](/apps-script/execution_web_apps),\nyou will see \"Hello, world!\" in the browser: \n\n function doGet() {\n return ContentService.createTextOutput('Hello, world!');\n }\n\nClasses\n-------\n\n| Name | Brief description |\n|------------------------------------------------------------------|----------------------------------------------------------|\n| [ContentService](/apps-script/reference/content/content-service) | Service for returning text content from a script. |\n| [MimeType](/apps-script/reference/content/mime-type) | An enum for mime types that can be served from a script. |\n| [TextOutput](/apps-script/reference/content/text-output) | A TextOutput object that can be served from a script. |\n\n[ContentService](/apps-script/reference/content/content-service)\n----------------------------------------------------------------\n\n### Properties\n\n| Property | Type | Description |\n|--------------|------------------------------------------------------|-------------|\n| `Mime``Type` | [MimeType](/apps-script/reference/content/mime-type) | |\n\n### Methods\n\n| Method | Return type | Brief description |\n|------------------------------------------------------------------------------------------------------|----------------------------------------------------------|----------------------------------------------------------------------------------------------------------------|\n| [createTextOutput()](/apps-script/reference/content/content-service#createTextOutput()) | [TextOutput](/apps-script/reference/content/text-output) | Create a new [TextOutput](/apps-script/reference/content/text-output) object. |\n| [createTextOutput(content)](/apps-script/reference/content/content-service#createTextOutput(String)) | [TextOutput](/apps-script/reference/content/text-output) | Create a new [TextOutput](/apps-script/reference/content/text-output) object that can serve the given content. |\n\n[MimeType](/apps-script/reference/content/mime-type)\n----------------------------------------------------\n\n### Properties\n\n| Property | Type | Description |\n|--------------|--------|----------------------|\n| `CSV` | `Enum` | CSV Mime Type |\n| `ICAL` | `Enum` | ICAL Mime Type |\n| `JAVASCRIPT` | `Enum` | JAVASCRIPT Mime Type |\n| `JSON` | `Enum` | JSON Mime Type |\n| `TEXT` | `Enum` | TEXT Mime Type |\n| `VCARD` | `Enum` | VCARD Mime Type |\n\n[TextOutput](/apps-script/reference/content/text-output)\n--------------------------------------------------------\n\n### Methods\n\n| Method | Return type | Brief description |\n|-----------------------------------------------------------------------------------------------|----------------------------------------------------------|-----------------------------------------------------------------------------------------------------------|\n| [append(addedContent)](/apps-script/reference/content/text-output#append(String)) | [TextOutput](/apps-script/reference/content/text-output) | Appends new content to the content that will be served. |\n| [clear()](/apps-script/reference/content/text-output#clear()) | [TextOutput](/apps-script/reference/content/text-output) | Clears the current content. |\n| [downloadAsFile(filename)](/apps-script/reference/content/text-output#downloadAsFile(String)) | [TextOutput](/apps-script/reference/content/text-output) | Tells browsers to download rather than display this content. |\n| [getContent()](/apps-script/reference/content/text-output#getContent()) | `String` | Gets the content that will be served. |\n| [getFileName()](/apps-script/reference/content/text-output#getFileName()) | `String` | Returns the file name to download this file as, or null if it should be displayed rather than downloaded. |\n| [getMimeType()](/apps-script/reference/content/text-output#getMimeType()) | [MimeType](/apps-script/reference/content/mime-type) | Get the mime type this content will be served with. |\n| [setContent(content)](/apps-script/reference/content/text-output#setContent(String)) | [TextOutput](/apps-script/reference/content/text-output) | Sets the content that will be served. |\n| [setMimeType(mimeType)](/apps-script/reference/content/text-output#setMimeType(MimeType)) | [TextOutput](/apps-script/reference/content/text-output) | Sets the mime type for content that will be served. |"]]