public function createTrack(File $video, UploadedFile $trackData, $lang, $label, $isDefault = false, $kind = 'subtitles')
 {
     $this->om->startFlushSuite();
     $trackFile = $this->fileManager->create(new File(), $trackData, $trackData->getClientOriginalName(), $trackData->getMimeType(), $video->getResourceNode()->getWorkspace());
     $this->om->persist($trackFile);
     $track = new Track();
     $track->setVideo($video);
     $track->setLang($lang);
     $track->setKind('subtitles');
     $track->setIsDefault($isDefault);
     $track->setTrackFile($trackFile);
     $track->setLabel($label);
     $this->om->persist($track);
     $this->om->endFlushSuite();
     return $track;
 }
Example #2
0
 public function uploadContent(File $file, UploadedFile $upload)
 {
     $ds = DIRECTORY_SEPARATOR;
     $node = $file->getResourceNode();
     $workspaceId = $node->getWorkspace()->getId();
     //edit file
     $fileName = $upload->getClientOriginalName();
     $size = @filesize($upload);
     $extension = pathinfo($fileName, PATHINFO_EXTENSION);
     $mimeType = $upload->getClientMimeType();
     $hashName = 'WORKSPACE_' . $workspaceId . $ds . $this->ut->generateGuid() . "." . $extension;
     $upload->move($this->fileDir . $ds . 'WORKSPACE_' . $workspaceId, $hashName);
     $file->setSize($size);
     $file->setHashName($hashName);
     $file->setMimeType($mimeType);
     //edit node
     $node->setMimeType($mimeType);
     $node->setName($fileName);
     //edit icon
     $this->om->persist($file);
     $this->om->persist($node);
     $this->om->flush();
 }
Example #3
0
 /**
  * @EXT\Route("/update/{file}", name="update_file", options = {"expose" = true})
  *
  * @EXT\Template("ClarolineCoreBundle:File:updateFileForm.html.twig")
  */
 public function updateFileAction(File $file)
 {
     $collection = new ResourceCollection(array($file->getResourceNode()));
     $this->checkAccess('EDIT', $collection);
     $request = $this->get('request');
     $form = $this->get('form.factory')->create(new UpdateFileType(), new File());
     $form->handleRequest($request);
     if ($form->isValid()) {
         $tmpFile = $form->get('file')->getData();
         $this->get('claroline.manager.file_manager')->changeFile($file, $tmpFile);
         if ($this->get('claroline.twig.home_extension')->isDesktop()) {
             $url = $this->generateUrl('claro_desktop_open_tool', array('toolName' => 'resource_manager'));
         } else {
             $url = $this->generateUrl('claro_workspace_open_tool', array('toolName' => 'resource_manager', 'workspaceId' => $file->getResourceNode()->getWorkspace()->getId()));
         }
         return $this->redirect($url);
     }
     return array('form' => $form->createView(), 'resourceType' => 'file', 'file' => $file, '_resource' => $file);
 }
 private function throwExceptionIfNotGranted(File $video, $permission)
 {
     $collection = new ResourceCollection([$video->getResourceNode()]);
     if (!$this->authorization->isGranted($permission, $collection)) {
         throw new AccessDeniedException($collection->getErrorsForDisplay());
     }
 }