CC-2404: Downloading a file via the web UI shouldn't guide user away from page.
-fixed
This commit is contained in:
parent
4d790ac42a
commit
141002eb49
2 changed files with 12 additions and 4 deletions
|
@ -54,7 +54,7 @@ class ApiController extends Zend_Controller_Action
|
||||||
* Allows remote client to download requested media file.
|
* Allows remote client to download requested media file.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
* The given value increased by the increment amount.
|
*
|
||||||
*/
|
*/
|
||||||
public function getMediaAction()
|
public function getMediaAction()
|
||||||
{
|
{
|
||||||
|
@ -65,7 +65,7 @@ class ApiController extends Zend_Controller_Action
|
||||||
$this->_helper->viewRenderer->setNoRender(true);
|
$this->_helper->viewRenderer->setNoRender(true);
|
||||||
|
|
||||||
$api_key = $this->_getParam('api_key');
|
$api_key = $this->_getParam('api_key');
|
||||||
$downlaod = $this->_getParam('download');
|
$download = ("true" == $this->_getParam('download'));
|
||||||
|
|
||||||
if(!in_array($api_key, $CC_CONFIG["apiKey"]))
|
if(!in_array($api_key, $CC_CONFIG["apiKey"]))
|
||||||
{
|
{
|
||||||
|
@ -87,7 +87,6 @@ class ApiController extends Zend_Controller_Action
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// possibly use fileinfo module here in the future.
|
// possibly use fileinfo module here in the future.
|
||||||
// http://www.php.net/manual/en/book.fileinfo.php
|
// http://www.php.net/manual/en/book.fileinfo.php
|
||||||
$ext = pathinfo($filename, PATHINFO_EXTENSION);
|
$ext = pathinfo($filename, PATHINFO_EXTENSION);
|
||||||
|
@ -96,7 +95,12 @@ class ApiController extends Zend_Controller_Action
|
||||||
else if ($ext == "mp3")
|
else if ($ext == "mp3")
|
||||||
header("Content-Type: audio/mpeg");
|
header("Content-Type: audio/mpeg");
|
||||||
if ($download){
|
if ($download){
|
||||||
header('Content-Disposition: attachment; filename="'.$media->getName().'"');
|
//path_info breaks up a file path into seperate pieces of informaiton.
|
||||||
|
//We just want the basename which is the file name with the path
|
||||||
|
//information stripped away. We are using Content-Disposition to specify
|
||||||
|
//to the browser what name the file should be saved as.
|
||||||
|
$path_parts = pathinfo($media->getPropelOrm()->getDbFilepath());
|
||||||
|
header('Content-Disposition: attachment; filename="'.$path_parts['basename'].'"');
|
||||||
}
|
}
|
||||||
header("Content-Length: " . filesize($filepath));
|
header("Content-Length: " . filesize($filepath));
|
||||||
|
|
||||||
|
|
|
@ -63,6 +63,10 @@ class StoredFile {
|
||||||
return $this->_file->getDbFtype();
|
return $this->_file->getDbFtype();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getPropelOrm(){
|
||||||
|
return $this->_file;
|
||||||
|
}
|
||||||
|
|
||||||
public function setFormat($p_format)
|
public function setFormat($p_format)
|
||||||
{
|
{
|
||||||
$this->_file->setDbFtype($p_format);
|
$this->_file->setDbFtype($p_format);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue