Refactored file storage code slightly to allow multiple download URLs
This commit is contained in:
parent
271dc266fa
commit
d31de0937f
11 changed files with 78 additions and 35 deletions
|
@ -138,8 +138,11 @@ SQL;
|
|||
if (isset($file_id)) {
|
||||
$file = Application_Model_StoredFile::RecallById($file_id);
|
||||
|
||||
if (isset($file) && file_exists($file->getFilePath())) {
|
||||
return $file;
|
||||
if (isset($file)) {
|
||||
$filePaths = $file->getFilePaths();
|
||||
if (file_exists($filePaths[0])) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -362,8 +362,9 @@ SQL;
|
|||
{
|
||||
$exists = false;
|
||||
try {
|
||||
$filePath = $this->getFilePath();
|
||||
$exists = (file_exists($this->getFilePath()) && !is_dir($filePath));
|
||||
$filePaths = $this->getFilePaths();
|
||||
$filePath = $filePaths[0];
|
||||
$exists = (file_exists($filePath) && !is_dir($filePath));
|
||||
} catch (Exception $e) {
|
||||
return false;
|
||||
}
|
||||
|
@ -444,8 +445,6 @@ SQL;
|
|||
*/
|
||||
public function deleteByMediaMonitor($deleteFromPlaylist=false)
|
||||
{
|
||||
$filepath = $this->getFilePath();
|
||||
|
||||
if ($deleteFromPlaylist) {
|
||||
Application_Model_Playlist::DeleteFileFromAllPlaylists($this->getId());
|
||||
}
|
||||
|
@ -499,13 +498,13 @@ SQL;
|
|||
/**
|
||||
* Get the absolute filepath
|
||||
*
|
||||
* @return string
|
||||
* @return array of strings
|
||||
*/
|
||||
public function getFilePath()
|
||||
public function getFilePaths()
|
||||
{
|
||||
assert($this->_file);
|
||||
|
||||
return $this->_file->getURLForTrackPreviewOrDownload();
|
||||
return $this->_file->getURLsForTrackPreviewOrDownload();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1238,9 +1237,11 @@ SQL;
|
|||
$genre = $file->getDbGenre();
|
||||
$release = $file->getDbUtime();
|
||||
try {
|
||||
$filePaths = $this->getFilePaths();
|
||||
$filePath = $filePaths[0];
|
||||
$soundcloud = new Application_Model_Soundcloud();
|
||||
$soundcloud_res = $soundcloud->uploadTrack(
|
||||
$this->getFilePath(), $this->getName(), $description,
|
||||
$filePath, $this->getName(), $description,
|
||||
$tag, $release, $genre);
|
||||
$this->setSoundCloudFileId($soundcloud_res['id']);
|
||||
$this->setSoundCloudLinkToFile($soundcloud_res['permalink_url']);
|
||||
|
|
|
@ -386,9 +386,9 @@ class CcFiles extends BaseCcFiles {
|
|||
/**
|
||||
* Returns the file's absolute file path stored on disk.
|
||||
*/
|
||||
public function getURLForTrackPreviewOrDownload()
|
||||
public function getURLsForTrackPreviewOrDownload()
|
||||
{
|
||||
return $this->getAbsoluteFilePath();
|
||||
return array($this->getAbsoluteFilePath());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -27,12 +27,12 @@ class CloudFile extends BaseCloudFile
|
|||
* requesting the file's object via this URL, it needs to be signed because
|
||||
* all objects stored on Amazon S3 are private.
|
||||
*/
|
||||
public function getURLForTrackPreviewOrDownload()
|
||||
public function getURLsForTrackPreviewOrDownload()
|
||||
{
|
||||
if ($this->proxyStorageBackend == null) {
|
||||
$this->proxyStorageBackend = new ProxyStorageBackend($this->getStorageBackend());
|
||||
}
|
||||
return $this->proxyStorageBackend->getSignedURL($this->getResourceId());
|
||||
return $this->proxyStorageBackend->getDownloadURLs($this->getResourceId());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue