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:
Class: ContentService
Service for returning text content from a script.
| Method | Description | Return Type | Return Description | Status | Implementation |
|---|---|---|---|---|---|
| createTextOutput() | Create a new TextOutput object. | TextOutput | the new TextOutput object. | completed | link |
| createTextOutput(String) | Create a new TextOutput object that can serve the given content. | TextOutput | the new TextOutput object. | completed | link |
Class: TextOutput
A TextOutput object that can be served from a script.
| Method | Description | Return Type | Return Description | Status | Implementation |
|---|---|---|---|---|---|
| append(String) | Appends new content to the content that will be served. | TextOutput | this TextOutput itself, useful for chaining | completed | link |
| clear() | Clears the current content. | TextOutput | this TextOutput itself, useful for chaining | completed | link |
| downloadAsFile(String) | Tells browsers to download rather than display this content. | TextOutput | the TextOutput object, useful for chaining | completed | link |
| getContent() | Gets the content that will be served. | String | the content that will be served | completed | link |
| getFileName() | Returns the file name to download this file as, or null if it should be displayed rather than downloaded. | String | the file name | completed | link |
| getMimeType() | Get the mime type this content will be served with. | MimeType | the mime type this will be served with | completed | link |
| setContent(String) | Sets the content that will be served. | TextOutput | this TextOutput itself, useful for chaining | completed | link |
| setMimeType(MimeType) | Sets the mime type for content that will be served. The default is plain text. | TextOutput | this TextOutput itself, useful for chaining | completed | link |
Enum: MimeType
An enum for mime types that can be served from a script.
| Property | Description | Status | Implementation |
|---|---|---|---|
| CSV | CSV Mime Type | completed | link |
| ICAL | ICAL Mime Type | completed | link |
| JAVASCRIPT | JAVASCRIPT Mime Type | completed | link |
| JSON | JSON Mime Type | completed | link |
| TEXT | TEXT Mime Type | completed | link |
| VCARD | VCARD Mime Type | completed | link |