CC-5896: Store cloud files in separate table, inherited from cc_files
This commit is contained in:
parent
b38f3d7e03
commit
f1ea100411
11 changed files with 165 additions and 130 deletions
|
@ -81,34 +81,10 @@ class ApiController extends Zend_Controller_Action
|
|||
|
||||
$media = Application_Model_StoredFile::RecallById($fileId);
|
||||
if ($media != null) {
|
||||
|
||||
if ($media->isInCloud()) {
|
||||
if ("true" == $this->_getParam('download')) {
|
||||
header('Content-type:'.$media->getPropelOrm()->getDbMime());
|
||||
header('Content-Disposition: attachment; filename="'.$media->getResourceId().'"');
|
||||
header('Content-length:'.$media->getFileSize());
|
||||
echo $media->getCloudUrl();
|
||||
exit;
|
||||
} else {
|
||||
$this->_redirect($media->getCloudUrl());
|
||||
}
|
||||
}
|
||||
|
||||
$filepath = $media->getFilePath();
|
||||
// Make sure we don't have some wrong result beecause of caching
|
||||
clearstatcache();
|
||||
if (is_file($filepath)) {
|
||||
$full_path = $media->getPropelOrm()->getDbFilepath();
|
||||
|
||||
$file_base_name = strrchr($full_path, '/');
|
||||
/* If $full_path does not contain a '/', strrchr will return false,
|
||||
* in which case we can use $full_path as the base name.
|
||||
*/
|
||||
if (!$file_base_name) {
|
||||
$file_base_name = $full_path;
|
||||
} else {
|
||||
$file_base_name = substr($file_base_name, 1);
|
||||
}
|
||||
if ($media->getPropelOrm()->isValidFile()) {
|
||||
$filename = $media->getPropelOrm()->getFilename();
|
||||
|
||||
//Download user left clicks a track and selects Download.
|
||||
if ("true" == $this->_getParam('download')) {
|
||||
|
@ -116,14 +92,13 @@ class ApiController extends Zend_Controller_Action
|
|||
//We just want the basename which is the file name with the path
|
||||
//information stripped away. We are using Content-Disposition to specify
|
||||
//to the browser what name the file should be saved as.
|
||||
header('Content-Disposition: attachment; filename="'.$file_base_name.'"');
|
||||
header('Content-Disposition: attachment; filename="'.$filename.'"');
|
||||
} else {
|
||||
//user clicks play button for track and downloads it.
|
||||
header('Content-Disposition: inline; filename="'.$file_base_name.'"');
|
||||
header('Content-Disposition: inline; filename="'.$filename.'"');
|
||||
}
|
||||
|
||||
$this->smartReadFile($filepath, $media->getPropelOrm()->getDbMime());
|
||||
exit;
|
||||
$this->_redirect($media->getFilePath());
|
||||
} else {
|
||||
header ("HTTP/1.1 404 Not Found");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue