SAAS-503: PYPO -> Use the REST API to download files
This commit is contained in:
parent
e1f1807f5a
commit
16dc286420
3 changed files with 21 additions and 21 deletions
|
@ -771,6 +771,9 @@ SQL;
|
|||
* @param Array $item schedule info about one track
|
||||
* @param Integer $media_id scheduled item's cc_files id
|
||||
* @param String $uri path to the scheduled item's physical location
|
||||
* @param String $downloadURL URL PYPO makes to the REST API to download the file for playout
|
||||
* @param Integer $filsize The file's file size in bytes
|
||||
*
|
||||
*/
|
||||
private static function createFileScheduleEvent(&$data, $item, $media_id, $uri, $downloadURL, $filesize)
|
||||
{
|
||||
|
@ -943,8 +946,9 @@ SQL;
|
|||
$storedFile = Application_Model_StoredFile::RecallById($media_id);
|
||||
$file = $storedFile->getPropelOrm();
|
||||
$uri = $file->getAbsoluteFilePath();
|
||||
// TODO: fix this URL
|
||||
$downloadURL = "http://localhost/rest/media/$media_id/download";
|
||||
|
||||
$baseUrl = Application_Common_OsPath::getBaseDir();
|
||||
$downloadURL = "http://".$_SERVER['HTTP_HOST'].$baseUrl."rest/media/$media_id/download";
|
||||
$filesize = $file->getFileSize();
|
||||
|
||||
self::createFileScheduleEvent($data, $item, $media_id, $uri, $downloadURL, $filesize);
|
||||
|
|
|
@ -70,9 +70,10 @@ class Rest_MediaController extends Zend_Rest_Controller
|
|||
$storedFile = new Application_Model_StoredFile($file, $con);
|
||||
$baseUrl = Application_Common_OsPath::getBaseDir();
|
||||
|
||||
$CC_CONFIG = Config::getConfig();
|
||||
$this->getResponse()
|
||||
->setHttpResponseCode(200)
|
||||
->appendBody($this->_redirect($storedFile->getRelativeFileUrl($baseUrl).'/download/true'));
|
||||
->appendBody($this->_redirect($storedFile->getRelativeFileUrl($baseUrl).'/download/true/api_key/'.$CC_CONFIG["apiKey"][0]));
|
||||
} else {
|
||||
$this->fileNotFoundResponse();
|
||||
}
|
||||
|
@ -307,7 +308,6 @@ class Rest_MediaController extends Zend_Rest_Controller
|
|||
$authHeader = $this->getRequest()->getHeader("Authorization");
|
||||
$encodedRequestApiKey = substr($authHeader, strlen("Basic "));
|
||||
$encodedStoredApiKey = base64_encode($CC_CONFIG["apiKey"][0] . ":");
|
||||
|
||||
if ($encodedRequestApiKey === $encodedStoredApiKey)
|
||||
{
|
||||
return true;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue