I have the following link on my website - http://mywebsite/multimedia/pronounciation/265.mp3
which gets me the file bypassing controllers. But I would like to log request and then return this file. So I created controller which logs request and then reroutes to the file:
class Controller_GetSound extends Controller {
public function action_index() {
Request::factory('multimedia/pronounciation/265.mp3')
->method(Request::POST)
->post($this->request->post())
->execute();
}
}
But it doesn't work as expected. How can I return resource file from controller?
Kohana has a send_file function. That function does a good job on splitting large files and sending correct mime types.
@see http://kohanaframework.org/3.3/guide-api/Response#send_file
Your code should be:
You actually don't really need to set the mime_type. Kohana will find the correct mime_type for your.