CC-5701: Airtime File API
Fixed saving filepath and directory
This commit is contained in:
parent
f7cb923ceb
commit
86a34635bb
1 changed files with 8 additions and 8 deletions
|
@ -115,15 +115,15 @@ class Rest_MediaController extends Zend_Rest_Controller
|
||||||
$file = CcFilesQuery::create()->findPk($id);
|
$file = CcFilesQuery::create()->findPk($id);
|
||||||
if ($file)
|
if ($file)
|
||||||
{
|
{
|
||||||
$fileFromJson = $file->fromArray($this->validateRequestData(json_decode($this->getRequest()->getRawBody(), true)),
|
$requestData = json_decode($this->getRequest()->getRawBody(), true);
|
||||||
BasePeer::TYPE_FIELDNAME);
|
$file->fromArray($this->validateRequestData($requestData), BasePeer::TYPE_FIELDNAME);
|
||||||
|
|
||||||
//Our RESTful API takes "full_path" as a field, which we then split and translate to match
|
//Our RESTful API takes "full_path" as a field, which we then split and translate to match
|
||||||
//our internal schema. Internally, file path is stored relative to a directory, with the directory
|
//our internal schema. Internally, file path is stored relative to a directory, with the directory
|
||||||
//as a foreign key to cc_music_dirs.
|
//as a foreign key to cc_music_dirs.
|
||||||
if ($fileFromJson["full_path"]) {
|
if ($requestData["full_path"]) {
|
||||||
|
|
||||||
$fullPath = $fileFromJson["full_path"];
|
$fullPath = $requestData["full_path"];
|
||||||
$storDir = Application_Model_MusicDir::getStorDir()->getDirectory();
|
$storDir = Application_Model_MusicDir::getStorDir()->getDirectory();
|
||||||
$pos = strpos($fullPath, $storDir);
|
$pos = strpos($fullPath, $storDir);
|
||||||
|
|
||||||
|
@ -132,8 +132,8 @@ class Rest_MediaController extends Zend_Rest_Controller
|
||||||
assert($pos == 0); //Path must start with the stor directory path
|
assert($pos == 0); //Path must start with the stor directory path
|
||||||
|
|
||||||
$filePathRelativeToStor = substr($fullPath, strlen($storDir));
|
$filePathRelativeToStor = substr($fullPath, strlen($storDir));
|
||||||
$fileFromJson["filepath"] = $filePathRelativeToStor;
|
$file->setDbFilepath($filePathRelativeToStor);
|
||||||
$fileFromJson["directory"] = 1; //1 corresponds to the default stor/imported directory.
|
$file->setDbDirectory(1); //1 corresponds to the default stor/imported directory.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue