Stay organized with collections Save and categorize content based on your preferences.
TextOutputA 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
ContentService
.
Detailed documentationappend(addedContent)
Appends new content to the content that will be served.
Parameters Name Type DescriptionaddedContent
String
the content to append Return
TextOutput
— this TextOutput itself, useful for chaining
clear()
Clears the current content.
ReturnTextOutput
— 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 Descriptionfilename
String
the filename to tell the browser to use Return
TextOutput
— the TextOutput object, useful for chaining
Error
— if the filename contains illegal characters
getContent()
Gets the content that will be served.
ReturnString
— 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.
ReturnString
— the file name
getMimeType()
Get the mime type this content will be served with.
ReturnMimeType
— the mime type this will be served with
setContent(content)
Sets the content that will be served.
Parameters Name Type Descriptioncontent
String
the content to serve Return
TextOutput
— 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 DescriptionmimeType
MimeType
the mime type Return
TextOutput
— this TextOutput itself, useful for chaining
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-12-02 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-12-02 UTC."],[[["A `TextOutput` object enables scripts to serve text content securely by redirecting the browser to `googleusercontent.com`."],["It offers methods to serve various content types such as JSON, RSS, and XML using the `ContentService`."],["Developers can manipulate the output using methods like `append`, `clear`, `downloadAsFile`, `getContent`, `getFileName`, `getMimeType`, `setContent`, and `setMimeType`."],["`TextOutput` enhances security by preventing direct return of text content to the browser from scripts."],["The `downloadAsFile` method enables content to be downloaded instead of displayed, offering flexibility in how the output is handled."]]],["TextOutput objects allow scripts to serve text content, which browsers access via redirection to googleusercontent.com. Key actions include: `append()` to add content, `clear()` to erase content, `downloadAsFile()` to trigger downloads, `getContent()` to retrieve content, `getFileName()` and `getMimeType()` to get metadata. `setContent()` sets the content, and `setMimeType()` specifies the content type. Scripts can use it to create outputs in text, JSON, RSS, and XML formats.\n"]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4