SAAS-922 - expose mime-based file extensions from /rest/media
This commit is contained in:
parent
0d27011e65
commit
92c9fd30b5
5 changed files with 51 additions and 68 deletions
|
@ -24,4 +24,31 @@ class FileDataHelper {
|
|||
$data["bpm"] = intval($data["bpm"]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a suitable extension for the given file
|
||||
*
|
||||
* @param string $mime
|
||||
*
|
||||
* @return string file extension with(!) a dot
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function getFileExtensionFromMime($mime)
|
||||
{
|
||||
if ($mime == "audio/ogg" || $mime == "application/ogg" || $mime == "audio/vorbis") {
|
||||
return ".ogg";
|
||||
} elseif ($mime == "audio/mp3" || $mime == "audio/mpeg" || $mime == "audio/mpeg3") {
|
||||
return ".mp3";
|
||||
} elseif ($mime == "audio/x-flac") {
|
||||
return ".flac";
|
||||
} elseif ($mime == "audio/mp4") {
|
||||
return ".mp4";
|
||||
} elseif ($mime == "audio/wav" || $mime == "audio/x-wav") {
|
||||
return ".wav";
|
||||
} else {
|
||||
throw new Exception("Unknown $mime");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -45,8 +45,6 @@ class Application_Common_HTTPHelper
|
|||
|
||||
class ZendActionHttpException extends Exception {
|
||||
|
||||
private $_action;
|
||||
|
||||
/**
|
||||
* @param Zend_Controller_Action $action
|
||||
* @param int $statusCode
|
||||
|
@ -58,8 +56,7 @@ class ZendActionHttpException extends Exception {
|
|||
*/
|
||||
public function __construct(Zend_Controller_Action $action, $statusCode, $message,
|
||||
$code = 0, Exception $previous = null) {
|
||||
$this->_action = $action;
|
||||
Logging::info("Error in action " . $action->getRequest()->getActionName()
|
||||
Logging::error("Error in action " . $action->getRequest()->getActionName()
|
||||
. " with status code $statusCode: $message");
|
||||
$action->getResponse()
|
||||
->setHttpResponseCode($statusCode)
|
||||
|
@ -67,8 +64,4 @@ class ZendActionHttpException extends Exception {
|
|||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
|
||||
public function getAction() {
|
||||
return $this->_action;
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue