TextOutput

A TextOutput object that can be served from a script.

Due to security considerations, scripts cannot directly return text content to a browser.
Instead, the browser is redirected to googleusercontent.com, which will display it without any
further sanitization or manipulation.

You can return text content like this:

```javascript
function doGet() {
  return ContentService.createTextOutput('hello world!');
}
```
There are also methods to serve JSON, RSS, and XML as TextOutputs; see the corresponding methods on `https://developers.google.com/apps-script/reference/content/content-service`.

### Methods

| Method | Return type | Brief description |
|---|---|---|
| `https://developers.google.com/apps-script/reference/content/text-output#append(String)` | `https://developers.google.com/apps-script/reference/content/text-output#` | Appends new content to the content that will be served. |
| `https://developers.google.com/apps-script/reference/content/text-output#clear()` | `https://developers.google.com/apps-script/reference/content/text-output#` | Clears the current content. |
| `https://developers.google.com/apps-script/reference/content/text-output#downloadAsFile(String)` | `https://developers.google.com/apps-script/reference/content/text-output#` | Tells browsers to download rather than display this content. |
| `https://developers.google.com/apps-script/reference/content/text-output#getContent()` | `String` | Gets the content that will be served. |
| `https://developers.google.com/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. |
| `https://developers.google.com/apps-script/reference/content/text-output#getMimeType()` | `https://developers.google.com/apps-script/reference/content/mime-type` | Get the mime type this content will be served with. |
| `https://developers.google.com/apps-script/reference/content/text-output#setContent(String)` | `https://developers.google.com/apps-script/reference/content/text-output#` | Sets the content that will be served. |
| `https://developers.google.com/apps-script/reference/content/text-output#setMimeType(MimeType)` | `https://developers.google.com/apps-script/reference/content/text-output#` | Sets the mime type for content that will be served. |

## Detailed documentation

### `append(addedContent)`

Appends new content to the content that will be served.

#### Parameters

| Name | Type | Description |
|---|---|---|
| `addedContent` | `String` | the content to append |

#### Return


`https://developers.google.com/apps-script/reference/content/text-output#` --- this TextOutput itself, useful for chaining

*** ** * ** ***

### `clear()`

Clears the current content.

#### Return


`https://developers.google.com/apps-script/reference/content/text-output#` --- this TextOutput itself, useful for chaining

*** ** * ** ***

### `downloadAsFile(filename)`

Tells browsers to download rather than display this content.

Some browsers will ignore this setting. Setting this to null will clear it back to the
default behavior of displaying rather than downloading.

#### Parameters

| Name | Type | Description |
|---|---|---|
| `filename` | `String` | the filename to tell the browser to use |

#### Return


`https://developers.google.com/apps-script/reference/content/text-output#` --- the TextOutput object, useful for chaining

#### Throws


[`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) --- if the filename contains illegal characters

*** ** * ** ***

### `getContent()`

Gets the content that will be served.

#### Return


`String` --- the content that will be served

*** ** * ** ***

### `getFileName()`

Returns the file name to download this file as, or null if it should be displayed rather than
downloaded.

#### Return


`String` --- the file name

*** ** * ** ***

### `getMimeType()`

Get the mime type this content will be served with.

#### Return


`https://developers.google.com/apps-script/reference/content/mime-type` --- the mime type this will be served with

*** ** * ** ***

### `setContent(content)`

Sets the content that will be served.

#### Parameters

| Name | Type | Description |
|---|---|---|
| `content` | `String` | the content to serve |

#### Return


`https://developers.google.com/apps-script/reference/content/text-output#` --- this TextOutput itself, useful for chaining

*** ** * ** ***

### `setMimeType(mimeType)`

Sets the mime type for content that will be served. The default is plain text.

#### Parameters

| Name | Type | Description |
|---|---|---|
| `mimeType` | `https://developers.google.com/apps-script/reference/content/mime-type` | the mime type |

#### Return


`https://developers.google.com/apps-script/reference/content/text-output#` --- this TextOutput itself, useful for chaining