CC-1799 Put Airtime Storage into a Human Readable File Naming Convention
regression testing with refactored storedfile, having permission problems unlinking a file.
This commit is contained in:
parent
1f9a39f22d
commit
a4b92fe72d
4 changed files with 45 additions and 17 deletions
|
@ -78,7 +78,7 @@ class ApiController extends Zend_Controller_Action
|
||||||
if (ctype_alnum($file_id) && strlen($file_id) == 32) {
|
if (ctype_alnum($file_id) && strlen($file_id) == 32) {
|
||||||
$media = StoredFile::RecallByGunid($file_id);
|
$media = StoredFile::RecallByGunid($file_id);
|
||||||
if ($media != null && !PEAR::isError($media)) {
|
if ($media != null && !PEAR::isError($media)) {
|
||||||
$filepath = $media->getRealFilePath();
|
$filepath = $media->getFilePath();
|
||||||
if(!is_file($filepath))
|
if(!is_file($filepath))
|
||||||
{
|
{
|
||||||
header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found");
|
header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found");
|
||||||
|
@ -419,7 +419,7 @@ class ApiController extends Zend_Controller_Action
|
||||||
|
|
||||||
//New file added to Airtime
|
//New file added to Airtime
|
||||||
if (is_null($file)) {
|
if (is_null($file)) {
|
||||||
$file = new StoredFile($md);
|
$file = StoredFile::Insert($md);
|
||||||
}
|
}
|
||||||
//Updating a metadata change.
|
//Updating a metadata change.
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -78,7 +78,7 @@ class LibraryController extends Zend_Controller_Action
|
||||||
$file_id = $this->_getParam('id', null);
|
$file_id = $this->_getParam('id', null);
|
||||||
$file = StoredFile::Recall($file_id);
|
$file = StoredFile::Recall($file_id);
|
||||||
|
|
||||||
$url = $file->getFileURL().'/api_key/'.$CC_CONFIG["apiKey"][0].'/download/true';
|
$url = $file->getFileUrl().'/api_key/'.$CC_CONFIG["apiKey"][0].'/download/true';
|
||||||
$menu[] = array('action' => array('type' => 'gourl', 'url' => $url),
|
$menu[] = array('action' => array('type' => 'gourl', 'url' => $url),
|
||||||
'title' => 'Download');
|
'title' => 'Download');
|
||||||
|
|
||||||
|
@ -162,10 +162,10 @@ class LibraryController extends Zend_Controller_Action
|
||||||
if ($form->isValid($request->getPost())) {
|
if ($form->isValid($request->getPost())) {
|
||||||
|
|
||||||
$formdata = $form->getValues();
|
$formdata = $form->getValues();
|
||||||
$file->replaceDbMetadata($formdata);
|
$file->setDbColMetadata($formdata);
|
||||||
|
|
||||||
$data = $formdata;
|
$data = $formdata;
|
||||||
$data['filepath'] = $file->getRealFilePath();
|
$data['filepath'] = $file->getFilePath();
|
||||||
//wait for 1.9.0 release
|
//wait for 1.9.0 release
|
||||||
//RabbitMq::SendFileMetaData($data);
|
//RabbitMq::SendFileMetaData($data);
|
||||||
|
|
||||||
|
@ -173,7 +173,7 @@ class LibraryController extends Zend_Controller_Action
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$form->populate($file->md);
|
$form->populate($file->getDbColMetadata());
|
||||||
$this->view->form = $form;
|
$this->view->form = $form;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,13 +43,9 @@ class StoredFile {
|
||||||
"md5" => "DbMd5"
|
"md5" => "DbMd5"
|
||||||
);
|
);
|
||||||
|
|
||||||
public function __construct($md)
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->_file = new CcFiles();
|
|
||||||
$this->_file->setDbGunid(md5(uniqid("", true)));
|
|
||||||
$this->_file->save();
|
|
||||||
|
|
||||||
$this->setMetadata($md);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getId()
|
public function getId()
|
||||||
|
@ -57,6 +53,10 @@ class StoredFile {
|
||||||
return $this->_file->getDbId();
|
return $this->_file->getDbId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getGunId() {
|
||||||
|
return $this->_file->getDbGunid();
|
||||||
|
}
|
||||||
|
|
||||||
public function getFormat()
|
public function getFormat()
|
||||||
{
|
{
|
||||||
return $this->_file->getDbFtype();
|
return $this->_file->getDbFtype();
|
||||||
|
@ -380,7 +380,30 @@ class StoredFile {
|
||||||
public function getFileUrl()
|
public function getFileUrl()
|
||||||
{
|
{
|
||||||
global $CC_CONFIG;
|
global $CC_CONFIG;
|
||||||
return "http://$CC_CONFIG[baseUrl]:$CC_CONFIG[basePort]/api/get-media/file/".$this->gunid.".".$this->getFileExtension();
|
return "http://$CC_CONFIG[baseUrl]:$CC_CONFIG[basePort]/api/get-media/file/".$this->getGunId().".".$this->getFileExtension();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function Insert($md=null)
|
||||||
|
{
|
||||||
|
$file = new CcFiles();
|
||||||
|
$file->setDbGunid(md5(uniqid("", true)));
|
||||||
|
$file->save();
|
||||||
|
|
||||||
|
if(isset($md)) {
|
||||||
|
if (preg_match("/mp3/i", $md['MDATA_KEY_MIME'])) {
|
||||||
|
$file->setDbFtype("audioclip");
|
||||||
|
}
|
||||||
|
else if (preg_match("/vorbis/i", $md['MDATA_KEY_MIME'])) {
|
||||||
|
$file->setDbFtype("audioclip");
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->setMetadata($md);
|
||||||
|
}
|
||||||
|
|
||||||
|
$storedFile = new StoredFile();
|
||||||
|
$storedFile->_file = $file;
|
||||||
|
|
||||||
|
return $storedFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -394,26 +417,26 @@ class StoredFile {
|
||||||
* global unique id of file
|
* global unique id of file
|
||||||
* @param string $p_md5sum
|
* @param string $p_md5sum
|
||||||
* MD5 sum of the file
|
* MD5 sum of the file
|
||||||
* @return StoredFile|Playlist|NULL
|
* @return StoredFile|NULL
|
||||||
* Return NULL if the object doesnt exist in the DB.
|
* Return NULL if the object doesnt exist in the DB.
|
||||||
*/
|
*/
|
||||||
public static function Recall($p_id=null, $p_gunid=null, $p_md5sum=null, $p_filepath=null)
|
public static function Recall($p_id=null, $p_gunid=null, $p_md5sum=null, $p_filepath=null)
|
||||||
{
|
{
|
||||||
if (isset($p_id)) {
|
if (isset($p_id)) {
|
||||||
$storedFile = CcFilesQuery::create()->findPK(intval($p_id));
|
$file = CcFilesQuery::create()->findPK(intval($p_id));
|
||||||
}
|
}
|
||||||
else if (isset($p_gunid)) {
|
else if (isset($p_gunid)) {
|
||||||
$storedFile = CcFilesQuery::create()
|
$file = CcFilesQuery::create()
|
||||||
->filterByDbGunid($p_gunid)
|
->filterByDbGunid($p_gunid)
|
||||||
->findOne();
|
->findOne();
|
||||||
}
|
}
|
||||||
else if (isset($p_md5sum)) {
|
else if (isset($p_md5sum)) {
|
||||||
$storedFile = CcFilesQuery::create()
|
$file = CcFilesQuery::create()
|
||||||
->filterByDbMd5($p_md5sum)
|
->filterByDbMd5($p_md5sum)
|
||||||
->findOne();
|
->findOne();
|
||||||
}
|
}
|
||||||
else if (isset($p_filepath)) {
|
else if (isset($p_filepath)) {
|
||||||
$storedFile = CcFilesQuery::create()
|
$file = CcFilesQuery::create()
|
||||||
->filterByDbFilepath($p_filepath)
|
->filterByDbFilepath($p_filepath)
|
||||||
->findOne();
|
->findOne();
|
||||||
}
|
}
|
||||||
|
@ -421,6 +444,9 @@ class StoredFile {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$storedFile = new StoredFile();
|
||||||
|
$storedFile->_file = $file;
|
||||||
|
|
||||||
return $storedFile;
|
return $storedFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -275,6 +275,8 @@ class MediaMonitor(ProcessEvent):
|
||||||
else :
|
else :
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def setUpMediaMonitor(self, event):
|
||||||
|
pass
|
||||||
|
|
||||||
def process_IN_CREATE(self, event):
|
def process_IN_CREATE(self, event):
|
||||||
if not event.dir:
|
if not event.dir:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue