We all need to deliver files to users at one point in time. ColdBox makes it easy to deliver any type of file even binary files via the Request Context's (event) sendFile() method.
/** * This method will send a file to the browser or requested HTTP protocol according to arguments. * CF11+ Compatibility * * @file The absolute path to the file or a binary file to send * @nameThe name to send to the browser via content disposition header. If not provided then the name of the file or a UUID for a binary file will be used * @mimeType A valid mime type to use. If not passed, then we will try to use one according to file type * @disposition The browser content disposition (attachment/inline) header * @abortAtEnd If true, then this method will do a hard abort, we do not recommend this, prefer the event.noRender() for a graceful abort. * @extension Only used for binary files which types are not determined. * @deleteFile Delete the file after it has been streamed to the user. Only used if file is not binary. */functionsendFile( file="", name="", mimeType="", disposition="attachment", boolean abortAtEnd="false", extension="", boolean deleteFile=false)
Please note that the file argument can be an absolute path or an actual binary file to stream out.