I'm building a download controller that reads a file from a location on the server, then passes that file along to the user after adding a few headers (at least that's what it's supposed to do). The controller extends my Base class, which itself is an extension of Controller_Template. Is there any acceptable method to halt execution of the app without rendering a template view? Or should I be rendering an empty view maybe? My downloader code looks like this:
public function action_download($id = null)
{
is_null($id) and \Response::redirect('/resources/files');
// specifying the client and category IDs prevents unauthorized access
$file = File::find($id, array('where' => array(
// @todo this is broken when a superuser uploads a file
Hah! I didn't realize there was a File class. It works great in my dev environment. What will I have to change for production? Do I have to globally disable output encoding or can I selectively bypass it?
If you use File::download(), nothing. It will disable output compression for you if it is enabled.
It will also wait with starting the download until after Fuel has finished execution, to avoid shutdown events messing up your download in case they produce output (like an error page for example).
You don't have to call exit or die after it, just a call to File::download() will suffice.