CC-5896: Store cloud files in separate table, inherited from cc_files
Fixed broken metadata display on Library page Fixed broken download/preview option from Library page
This commit is contained in:
parent
f1ea100411
commit
ecb072b84c
|
@ -83,8 +83,10 @@ class ApiController extends Zend_Controller_Action
|
||||||
if ($media != null) {
|
if ($media != null) {
|
||||||
// Make sure we don't have some wrong result beecause of caching
|
// Make sure we don't have some wrong result beecause of caching
|
||||||
clearstatcache();
|
clearstatcache();
|
||||||
|
|
||||||
if ($media->getPropelOrm()->isValidFile()) {
|
if ($media->getPropelOrm()->isValidFile()) {
|
||||||
$filename = $media->getPropelOrm()->getFilename();
|
//$filename = $media->getPropelOrm()->getFilename();
|
||||||
|
$filename = $media->getPropelOrm()->getDbFilepath();
|
||||||
|
|
||||||
//Download user left clicks a track and selects Download.
|
//Download user left clicks a track and selects Download.
|
||||||
if ("true" == $this->_getParam('download')) {
|
if ("true" == $this->_getParam('download')) {
|
||||||
|
@ -94,11 +96,13 @@ class ApiController extends Zend_Controller_Action
|
||||||
//to the browser what name the file should be saved as.
|
//to the browser what name the file should be saved as.
|
||||||
header('Content-Disposition: attachment; filename="'.$filename.'"');
|
header('Content-Disposition: attachment; filename="'.$filename.'"');
|
||||||
} else {
|
} else {
|
||||||
//user clicks play button for track and downloads it.
|
//user clicks play button for track preview
|
||||||
header('Content-Disposition: inline; filename="'.$filename.'"');
|
header('Content-Disposition: inline; filename="'.$filename.'"');
|
||||||
|
$this->_redirect($media->getFilePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_redirect($media->getFilePath());
|
$this->smartReadFile($media);
|
||||||
|
exit;
|
||||||
} else {
|
} else {
|
||||||
header ("HTTP/1.1 404 Not Found");
|
header ("HTTP/1.1 404 Not Found");
|
||||||
}
|
}
|
||||||
|
@ -119,12 +123,13 @@ class ApiController extends Zend_Controller_Action
|
||||||
* @link https://groups.google.com/d/msg/jplayer/nSM2UmnSKKA/Hu76jDZS4xcJ
|
* @link https://groups.google.com/d/msg/jplayer/nSM2UmnSKKA/Hu76jDZS4xcJ
|
||||||
* @link http://php.net/manual/en/function.readfile.php#86244
|
* @link http://php.net/manual/en/function.readfile.php#86244
|
||||||
*/
|
*/
|
||||||
public function smartReadFile($location, $mimeType = 'audio/mp3')
|
public function smartReadFile($media)
|
||||||
{
|
{
|
||||||
$size= filesize($location);
|
$filepath = $media->getFilePath();
|
||||||
$time= date('r', filemtime($location));
|
$size= $media->getFileSize();
|
||||||
|
$mimeType = $media->getPropelOrm()->getDbMime();
|
||||||
|
|
||||||
$fm = @fopen($location, 'rb');
|
$fm = @fopen($filepath, 'rb');
|
||||||
if (!$fm) {
|
if (!$fm) {
|
||||||
header ("HTTP/1.1 505 Internal server error");
|
header ("HTTP/1.1 505 Internal server error");
|
||||||
|
|
||||||
|
@ -157,19 +162,22 @@ class ApiController extends Zend_Controller_Action
|
||||||
header("Content-Range: bytes $begin-$end/$size");
|
header("Content-Range: bytes $begin-$end/$size");
|
||||||
}
|
}
|
||||||
header("Content-Transfer-Encoding: binary");
|
header("Content-Transfer-Encoding: binary");
|
||||||
header("Last-Modified: $time");
|
|
||||||
|
|
||||||
//We can have multiple levels of output buffering. Need to
|
//We can have multiple levels of output buffering. Need to
|
||||||
//keep looping until all have been disabled!!!
|
//keep looping until all have been disabled!!!
|
||||||
//http://www.php.net/manual/en/function.ob-end-flush.php
|
//http://www.php.net/manual/en/function.ob-end-flush.php
|
||||||
while (@ob_end_flush());
|
while (@ob_end_flush());
|
||||||
|
|
||||||
$cur = $begin;
|
/*$cur = $begin;
|
||||||
fseek($fm, $begin, 0);
|
fseek($fm, $begin, 0);
|
||||||
|
|
||||||
while (!feof($fm) && $cur <= $end && (connection_status() == 0)) {
|
while (!feof($fm) && $cur <= $end && (connection_status() == 0)) {
|
||||||
echo fread($fm, min(1024 * 16, ($end - $cur) + 1));
|
echo fread($fm, min(1024 * 16, ($end - $cur) + 1));
|
||||||
$cur += 1024 * 16;
|
$cur += 1024 * 16;
|
||||||
|
}*/
|
||||||
|
|
||||||
|
while(!feof($fm)) {
|
||||||
|
echo fread($fm, 1024 * 8);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -481,7 +481,7 @@ class LibraryController extends Zend_Controller_Action
|
||||||
$md = $file->getMetadata();
|
$md = $file->getMetadata();
|
||||||
|
|
||||||
foreach ($md as $key => $value) {
|
foreach ($md as $key => $value) {
|
||||||
if ($key == 'MDATA_KEY_DIRECTORY') {
|
if ($key == 'MDATA_KEY_DIRECTORY' && !is_null($value)) {
|
||||||
$musicDir = Application_Model_MusicDir::getDirByPK($value);
|
$musicDir = Application_Model_MusicDir::getDirByPK($value);
|
||||||
$md['MDATA_KEY_FILEPATH'] = Application_Common_OsPath::join($musicDir->getDirectory(), $md['MDATA_KEY_FILEPATH']);
|
$md['MDATA_KEY_FILEPATH'] = Application_Common_OsPath::join($musicDir->getDirectory(), $md['MDATA_KEY_FILEPATH']);
|
||||||
}
|
}
|
||||||
|
|
|
@ -226,6 +226,9 @@ class Rest_MediaController extends Zend_Rest_Controller
|
||||||
|
|
||||||
//file is stored in the cloud
|
//file is stored in the cloud
|
||||||
if (isset($requestData["resource_id"])) {
|
if (isset($requestData["resource_id"])) {
|
||||||
|
//store the original filename
|
||||||
|
$file->setDbFilepath($requestData["filename"]);
|
||||||
|
|
||||||
$fileSizeBytes = $requestData["filesize"];
|
$fileSizeBytes = $requestData["filesize"];
|
||||||
$cloudFile = new CloudFile();
|
$cloudFile = new CloudFile();
|
||||||
$cloudFile->setResourceId($requestData["resource_id"]);
|
$cloudFile->setResourceId($requestData["resource_id"]);
|
||||||
|
|
|
@ -41,6 +41,9 @@ class CloudStorageUploader:
|
||||||
except OSError:
|
except OSError:
|
||||||
logging.info("Could not remove %s from organize directory" % audio_file_path)
|
logging.info("Could not remove %s from organize directory" % audio_file_path)
|
||||||
|
|
||||||
|
'''pass original filename to Airtime so we can store it in the db'''
|
||||||
|
metadata["filename"] = file_base_name
|
||||||
|
|
||||||
metadata["resource_id"] = object_name
|
metadata["resource_id"] = object_name
|
||||||
return metadata
|
return metadata
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue