Skip to content

Instantly share code, notes, and snippets.

@bennadel
Created March 24, 2014 23:53
Show Gist options
  • Save bennadel/9752015 to your computer and use it in GitHub Desktop.
Save bennadel/9752015 to your computer and use it in GitHub Desktop.
Streaming Text Using ColdFusion's CFContent Tag And The Variable Attribute
<!---
Store the text you want to stream. This could be done
here, or it could be gotten from a different part of
the application.
--->
<cfsavecontent variable="strText">
This is some cool text.
</cfsavecontent>
<!--- Set the header info to force that file attachment. --->
<cfheader
name="Content-Disposition"
value="attachment; filename=streamed_text.txt"
/>
<!---
Stream the text. To do so, we have to convert it to
Base64 first, then convert that to binary.
--->
<cfcontent
type="text/plain"
reset="true"
variable="#ToBinary( ToBase64( strText ) )#"
/>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment