More work on show image uploading functionality
This commit is contained in:
parent
cb80423fdd
commit
2a2fcdcf10
9 changed files with 119 additions and 79 deletions
|
@ -445,6 +445,45 @@ class Rest_MediaController extends Zend_Rest_Controller
|
|||
$importedStorageDirectory, basename($originalFilename),
|
||||
$callbackUrl, $apiKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is here until an image-specific Rest Controller is set up
|
||||
*/
|
||||
public static function processUploadedImage($tempFilePath, $originalFilename) {
|
||||
$ownerId = $this->getOwnerId();
|
||||
|
||||
$CC_CONFIG = Config::getConfig();
|
||||
$apiKey = $CC_CONFIG["apiKey"][0];
|
||||
|
||||
$tempFileName = basename($tempFilePath);
|
||||
|
||||
//Only accept files with a file extension that we support.
|
||||
$fileExtension = pathinfo($originalFilename, PATHINFO_EXTENSION);
|
||||
if (!in_array(strtolower($fileExtension), explode(",", "jpg,png,gif")))
|
||||
{
|
||||
@unlink($tempFilePath);
|
||||
throw new Exception("Bad file extension.");
|
||||
}
|
||||
|
||||
$storDir = Application_Model_MusicDir::getStorDir();
|
||||
$importedStorageDirectory = $storDir->getDirectory() . "/show-images/" . $ownerId;
|
||||
|
||||
try {
|
||||
//Copy the temporary file over to the "organize" folder so that it's off our webserver
|
||||
//and accessible by airtime_analyzer which could be running on a different machine.
|
||||
$newTempFilePath = Application_Model_StoredFile::copyFileToStor($tempFilePath, $originalFilename);
|
||||
} catch (Exception $e) {
|
||||
@unlink($tempFilePath);
|
||||
Logging::error($e->getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
//Dispatch a message to airtime_analyzer through RabbitMQ,
|
||||
//notifying it that there's a new upload to process!
|
||||
Application_Model_RabbitMq::SendMessageToAnalyzer($newTempFilePath,
|
||||
$importedStorageDirectory, basename($originalFilename),
|
||||
null, $apiKey);
|
||||
}
|
||||
|
||||
private function getOwnerId()
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue