示例#1
0
 /**
  * actionCreate
  *
  * PUT /resource -> actionCreate -> Create the resource
  *
  * @return bool|Video
  */
 public function actionCreate()
 {
     try {
         $uploadedFile = new UploadedFile('data');
         if (!$uploadedFile) {
             throw new ActionCreateException("Error uploading file");
         }
         if (!$uploadedFile->checkAllowedExtension(self::EXTENSION_SOURSE)) {
             throw new ActionCreateException("File extension is not as expected");
         }
         $fileName = $this->documentPath . uniqid() . self::EXTENSION_SOURSE;
         $uloadResult = $uploadedFile->upload($fileName);
         if ($uloadResult !== true) {
             throw new ActionCreateException($uloadResult);
         }
     } catch (ActionCreateException $e) {
         return $e->getMessage();
     }
     $newName = $this->documentPath . uniqid() . self::EXTENSION_DESTINATION;
     return Video::addVideo($uploadedFile->originalName, $fileName, $newName, $this->currentUserId());
 }