CFCONTENT

Controls the MIMETYPE of the page, or sends out a file, remote object or binary object to the requester

Usage

<cfcontent>

Attributes

Attribute default required summary
ATTRIBUTECOLLECTION A structure containing the tag attributes
TYPE The MIME TYPE of the output page
RESET true Controls whether the existing content sent is discarded
DELETEFILE false If FILE specified, controls whether the file is deleted once its sent
FILE The path to the file
REMOTE Structure detailing the remote object to fetch and send straight to the client without buffering. S3 and HTTP supported
OUTPUT The variable that contains the content to send to the request
VARIABLE The variable that contains the content to send to the request
URIDIRECTORY false Is the path to the file relative to the document root

Extra

This tag allows you to stream remote content straight to the client without first buffering or saving it locally. Particularly useful when you are proxying internal content to the outside world, or if you wish to protect resources using a custom security model.

Note this technique uses very little memory, as the content is streamed in realtime from the remote resource straight to the client.

There are two supported remote types:

  • type : "http"
  • type : "s3"

type : "http"

To proxy a remote URL, then set the type to "http" and pass in the remote URL. The ContentType of the remote resource will be sent to the client.

<cfset remote={
  type : "http",
  url : "http://openbd.org/manual/images/logo.png"
} />

<cfcontent remote="#remote#" />

type : "s3"

You can proxy a remote Amazon S3 resource, by setting type to "s3". The Amazon datasource must be pre-registered and then you set at least the bucket and the key of the remote object. You can optionally set the aes256key encryption key that the original file was uploaded to.

<cfset remote={
  type : "s3",
  datasource : "amz",
  bucket : "your-bucket",
  key : "a/b/c/yourkey.jpg",
  aes256key : "optional"
} />

<cfcontent remote="#remote#" />