added logging to ApiController::getMediaAction
-Will help us see why files are not sometimes downloaded by pypo.
This commit is contained in:
parent
7e1dbf8085
commit
dc457e79a0
1 changed files with 43 additions and 37 deletions
|
@ -68,11 +68,14 @@ class ApiController extends Zend_Controller_Action
|
|||
$api_key = $this->_getParam('api_key');
|
||||
$download = ("true" == $this->_getParam('download'));
|
||||
|
||||
$logger = Logging::getLogger();
|
||||
|
||||
if(!in_array($api_key, $CC_CONFIG["apiKey"]))
|
||||
{
|
||||
header('HTTP/1.0 401 Unauthorized');
|
||||
print 'You are not allowed to access this resource.';
|
||||
exit;
|
||||
$logger->info("401 Unauthorized");
|
||||
return;
|
||||
}
|
||||
|
||||
$filename = $this->_getParam("file");
|
||||
|
@ -81,13 +84,7 @@ class ApiController extends Zend_Controller_Action
|
|||
$media = StoredFile::RecallByGunid($file_id);
|
||||
if ($media != null && !PEAR::isError($media)) {
|
||||
$filepath = $media->getFilePath();
|
||||
if(!is_file($filepath))
|
||||
{
|
||||
header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found");
|
||||
//print 'Resource in database, but not in storage. Sorry.';
|
||||
exit;
|
||||
}
|
||||
|
||||
if(is_file($filepath)){
|
||||
// possibly use fileinfo module here in the future.
|
||||
// http://www.php.net/manual/en/book.fileinfo.php
|
||||
$ext = pathinfo($filename, PATHINFO_EXTENSION);
|
||||
|
@ -116,11 +113,20 @@ class ApiController extends Zend_Controller_Action
|
|||
fpassthru($fp);
|
||||
fclose($fp);
|
||||
|
||||
return;
|
||||
//make sure to exit here so that no other output is sent.
|
||||
exit;
|
||||
} else {
|
||||
$logger->err('Resource in database, but not in storage: '.$filepath.' '.is_file($filepath));
|
||||
}
|
||||
} else {
|
||||
$logger->err('$media != null && !PEAR::isError($media)');
|
||||
}
|
||||
} else {
|
||||
$logger->err('ctype_alnum($file_id) && strlen($file_id) == 32');
|
||||
}
|
||||
header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found");
|
||||
exit;
|
||||
$logger->info("404 Not Found");
|
||||
return;
|
||||
}
|
||||
|
||||
public function liveInfoAction()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue