Hi,
I am having trouble with sending a file to the browser. I have had this working in the past but now I am trying to implement my test code from several months ago and it is no longer working.
In my controller method I have this (simplified) code:
function get_audio() {
$this->sendFile('/myDir/AudioFilename.mp3', array('type' => 'audio/mpeg',
'disposition' => 'attachment',
'filename' => $file_name));
}
The file gets sent to the browser as an attachment but it has
Content-Type: text/html
which of course is not very useful for an audio file!
After doing some digging it appears that the sendFile method sets the headers for the response in _sendFileHeaders(). Later in preparation for sending the response _sendMimeContentType() uses the request format to set the content-type. This is where the type set when calling sendFile gets overwritten.
I am not familiar enough to make a change but either I am doing something wrong or else perhaps a clause could be added in AkResponse->setContentTypeForFormat() like this.
function setContentTypeForFormat($format)
{
if (empty($this->_headers['Content-Type'])) { // <-- added check
if (!empty($format)) {
$mime_type = Ak::mime_content_type('file.'.$format);
if (!empty($mime_type)) {
$this->addHeader('Content-Type', $mime_type);
}
}
} // <-- closing bracket
}
Perhaps someone with more experience in akelos internals could comment.
Thanks for your help.
Todd
1 to 1 of 1