Exemplo n.º 1
0
 /**
  * 
  * @return void
  */
 public function uploadx()
 {
     $upload = new ResumeUpload();
     //$upload->setTempName('newName');
     $upload->setMainDirectory($this->uploadfile->getUploadFolder());
     return $upload->upload();
 }
Exemplo n.º 2
0
 /**
  * Big Upload 
  * ini adalah upload menggunakan metode chuck 
  * dengan ajax file
  */
 public function bigUploads()
 {
     $bigUpload = new BigUpload();
     $folder = $this->uploadfile->getUploadFolder();
     $bigUpload->setTempDirectory(public_path('/videos/tmp'));
     $bigUpload->setMainDirectory($folder);
     $bigUpload->setTempName(Input::get('key', null));
     switch (Input::get('action')) {
         case 'upload':
             return $bigUpload->uploadFile();
             break;
         case 'abort':
             return $bigUpload->abortUpload();
             break;
         case 'finish':
             $rand = Str::random(10);
             $randomname = $rand . '.' . Input::get('ext');
             $finish = $bigUpload->finishUpload($randomname);
             if (0 === $finish['errorStatus']) {
                 // Create a new order if not exist
                 if (null === $this->model) {
                     $this->model = $this->repository->getModel()->newInstance();
                     /*
                     //shell_exec("ffmpegthumbnailer -i " . $folder. $randomname ." -o ". static::$app['path.base']."/public/covers/" . $rand . ".png -s 400"); 
                     shell_exec("ffmpeg  -itsoffset -5  -i ". $folder. $randomname  ." -vcodec mjpeg -vframes 5 -an -f rawvideo  ".static::$app['path.base']."/public/covers/" . $rand . ".jpg");
                     //Sonus::convert()->input( $folder. $randomname )->output(static::$app['path.base'].'/public/streams/' . $randomname )->go();
                     $resolusi = $this->__get_video_dimensions($folder.$randomname);
                     if($resolusi['height'] >= 720){
                       shell_exec("ffmpeg -i {$folder}{$randomname} -s 960x720 -vcodec h264 -acodec aac -strict -2 {$folder}{$rand}_720.mp4");  
                     }
                     shell_exec("ffmpeg -i {$folder}{$randomname} -s 480×360 -vcodec h264 -acodec aac -strict -2 {$folder}{$rand}_360.mp4");
                     */
                     // File extension
                     $this->model->code = $rand;
                     $this->model->extension = File::extension($folder . $randomname);
                     $this->model->mimetype = File::type($folder . $randomname);
                     $this->model->owner_id = $this->ownerId;
                     $this->model->size = File::size($folder . $randomname);
                     $this->model->path = $this->uploadfile->cleanPath(static::$app['config']->get('video.upload_folder_public_path')) . $this->uploadfile->dateFolderPath;
                     $this->model->filename = $randomname;
                     $this->model->playback = $randomname;
                     $this->model->cover = $rand . '.png';
                     $this->model->save();
                     if (null !== $this->model) {
                         $info = $this->infoRepository->getModel()->where('video_id', $this->model->getId())->first();
                         // Create a new item
                         $info = $info ? $info : $this->infoRepository->getModel()->newInstance();
                         $info->fill(array_merge(array('name' => Input::get('name')), array('video_id' => $this->model->getId())));
                         if (!$info->save()) {
                             throw new Exception("Could not create a video info");
                         }
                     }
                 }
                 return array('errorStatus' => 0, 'id' => $this->model->getId(), 'code' => $this->model->code);
             }
             return $finish;
             break;
         case 'post-unsupported':
             //return $bigUpload->postUnsupported();
             return $this->upload(Input::file('bigUploadFile'));
             break;
     }
 }