public function getFiles()
 {
     /** Should we cached find result? */
     $files = $this->mediaManager->find($this->fileFilter);
     if ($files instanceof IFile) {
         //just single file
         return [$files];
     } else {
         return $files;
     }
 }
Ejemplo n.º 2
0
 public function actionDefault($name, $size = null)
 {
     try {
         /** @var IImage $image */
         $image = $this->mediaManager->publishIcon($name, $size);
     } catch (FileNotFoundException $e) {
         throw new BadRequestException($e->getMessage(), 404, $e);
     }
     header('Content-Type: ' . $image->getContentType());
     $this->sendResponse(new FileContentResponse($image->save(null, null, $image->getImageType()), $image->getName(), $image->getContentType(), false));
 }
Ejemplo n.º 3
0
 public function actionDefault($name, $namespace = null)
 {
     try {
         /** @var IFile $image */
         $file = $this->mediaManager->publishFile($name);
     } catch (FileNotFoundException $e) {
         throw new BadRequestException($e->getMessage(), 404, $e);
     }
     header('Content-Type: ' . $file->getContentType());
     $this->sendResponse(new FileResponse($file->getFullPath(), $file->getName(), null, false));
 }
Ejemplo n.º 4
0
 public function handleUpload(Form $form, $values)
 {
     try {
         if (is_array($values['upload'])) {
             /** @var FileUpload $fileUpload */
             foreach ($values['upload'] as $fileUpload) {
                 $file = \vojtabiberle\MediaStorage\Bridges\Nette\Http\FileUpload::createFromNetteFileUpload($fileUpload);
                 $this->manager->save($file);
                 $this->presenter->flashMessage('File "' . $file->getName() . '" was uploaded');
             }
         } else {
             throw new NoFileUploadedException('No files was uploaded');
         }
     } catch (RuntimeException $e) {
         $this->presenter->flashMessage($e->getMessage(), 'error');
     }
 }
 public function handleDelete($uid)
 {
     $this->mediaManager->deleteById($uid);
     $this->redrawControl('gridMediaFiles');
 }