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) {
|
||||
// Make sure we don't have some wrong result beecause of caching
|
||||
clearstatcache();
|
||||
|
||||
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.
|
||||
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.
|
||||
header('Content-Disposition: attachment; filename="'.$filename.'"');
|
||||
} else {
|
||||
//user clicks play button for track and downloads it.
|
||||
//user clicks play button for track preview
|
||||
header('Content-Disposition: inline; filename="'.$filename.'"');
|
||||
$this->_redirect($media->getFilePath());
|
||||
}
|
||||
|
||||
$this->_redirect($media->getFilePath());
|
||||
$this->smartReadFile($media);
|
||||
exit;
|
||||
} else {
|
||||
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 http://php.net/manual/en/function.readfile.php#86244
|
||||
*/
|
||||
public function smartReadFile($location, $mimeType = 'audio/mp3')
|
||||
public function smartReadFile($media)
|
||||
{
|
||||
$size= filesize($location);
|
||||
$time= date('r', filemtime($location));
|
||||
$filepath = $media->getFilePath();
|
||||
$size= $media->getFileSize();
|
||||
$mimeType = $media->getPropelOrm()->getDbMime();
|
||||
|
||||
$fm = @fopen($location, 'rb');
|
||||
$fm = @fopen($filepath, 'rb');
|
||||
if (!$fm) {
|
||||
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-Transfer-Encoding: binary");
|
||||
header("Last-Modified: $time");
|
||||
|
||||
//We can have multiple levels of output buffering. Need to
|
||||
//keep looping until all have been disabled!!!
|
||||
//http://www.php.net/manual/en/function.ob-end-flush.php
|
||||
while (@ob_end_flush());
|
||||
|
||||
$cur = $begin;
|
||||
/*$cur = $begin;
|
||||
fseek($fm, $begin, 0);
|
||||
|
||||
while (!feof($fm) && $cur <= $end && (connection_status() == 0)) {
|
||||
echo fread($fm, min(1024 * 16, ($end - $cur) + 1));
|
||||
$cur += 1024 * 16;
|
||||
}*/
|
||||
|
||||
while(!feof($fm)) {
|
||||
echo fread($fm, 1024 * 8);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -481,7 +481,7 @@ class LibraryController extends Zend_Controller_Action
|
|||
$md = $file->getMetadata();
|
||||
|
||||
foreach ($md as $key => $value) {
|
||||
if ($key == 'MDATA_KEY_DIRECTORY') {
|
||||
if ($key == 'MDATA_KEY_DIRECTORY' && !is_null($value)) {
|
||||
$musicDir = Application_Model_MusicDir::getDirByPK($value);
|
||||
$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
|
||||
if (isset($requestData["resource_id"])) {
|
||||
//store the original filename
|
||||
$file->setDbFilepath($requestData["filename"]);
|
||||
|
||||
$fileSizeBytes = $requestData["filesize"];
|
||||
$cloudFile = new CloudFile();
|
||||
$cloudFile->setResourceId($requestData["resource_id"]);
|
||||
|
|
|
@ -41,6 +41,9 @@ class CloudStorageUploader:
|
|||
except OSError:
|
||||
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
|
||||
return metadata
|
||||
|
||||
|
|
Loading…
Reference in New Issue