This service allows scripts to serve text in various forms, such as text, XML, or JSON. See also the guide to Content Service. If you deploy the following script as a web app, you will see "Hello, world!" in the browser:
function doGet() {
return ContentService.createTextOutput('Hello, world!');
}
Classes
Name | Brief description |
---|---|
ContentService | Service for returning text content from a script. |
MimeType | An enum for mime types that can be served from a script. |
TextOutput | A TextOutput object that can be served from a script. |
ContentService
Properties
Property | Type | Description |
---|---|---|
MimeType | MimeType |
Methods
Method | Return type | Brief description |
---|---|---|
createTextOutput() | TextOutput | Create a new TextOutput object. |
createTextOutput(content) | TextOutput | Create a new TextOutput object that can serve the given content. |
MimeType
Properties
Property | Type | Description |
---|---|---|
CSV | Enum | CSV Mime Type |
ICAL | Enum | ICAL Mime Type |
JAVASCRIPT | Enum | JAVASCRIPT Mime Type |
JSON | Enum | JSON Mime Type |
TEXT | Enum | TEXT Mime Type |
VCARD | Enum | VCARD Mime Type |
TextOutput
Methods
Method | Return type | Brief description |
---|---|---|
append(addedContent) | TextOutput | Appends new content to the content that will be served. |
clear() | TextOutput | Clears the current content. |
downloadAsFile(filename) | TextOutput | Tells browsers to download rather than display this content. |
getContent() | String | Gets the content that will be served. |
getFileName() | String | Returns the file name to download this file as, or null if it should be displayed rather than downloaded. |
getMimeType() | MimeType | Get the mime type this content will be served with. |
setContent(content) | TextOutput | Sets the content that will be served. |
setMimeType(mimeType) | TextOutput | Sets the mime type for content that will be served. |