Class TextOutput

Text Output

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:

 function 
  
 doGet 
 () 
  
 { 
  
 return 
  
 ContentService 
 . 
 createTextOutput 
 ( 
 'hello world!' 
 ); 
 } 
There are also methods to serve JSON, RSS, and XML as TextOutputs; see the corresponding methods on Content Service .

Methods

Method Return type Brief description
Text Output Appends new content to the content that will be served.
Text Output Clears the current content.
Text Output Tells browsers to download rather than display this content.
String Gets the content that will be served.
String Returns the file name to download this file as, or null if it should be displayed rather than downloaded.
Mime Type Get the mime type this content will be served with.
Text Output Sets the content that will be served.
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
added Content
String the content to append

Return

Text Output — this TextOutput itself, useful for chaining


clear()

Clears the current content.

Return

Text Output — this TextOutput itself, useful for chaining


download As File(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

Text Output — the TextOutput object, useful for chaining

Throws

Error — if the filename contains illegal characters


get Content()

Gets the content that will be served.

Return

String — the content that will be served


get File Name()

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

Return

String — the file name


get Mime Type()

Get the mime type this content will be served with.

Return

Mime Type — the mime type this will be served with


set Content(content)

Sets the content that will be served.

Parameters

Name Type Description
content
String the content to serve

Return

Text Output — this TextOutput itself, useful for chaining


set Mime Type(mimeType)

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

Parameters

Name Type Description
mime Type
Mime Type the mime type

Return

Text Output — this TextOutput itself, useful for chaining

Create a Mobile Website
View Site in Mobile | Classic
Share by: