/** * Render a thumbnail of a media * * @throws MissingTcaConfigurationException * @return string */ public function create() { if (empty($this->file)) { throw new MissingTcaConfigurationException('Missing File object. Forgotten to set a file?', 1355933144); } // Default class name $className = 'Fab\\Media\\Thumbnail\\FallBackThumbnailProcessor'; if (File::FILETYPE_IMAGE == $this->file->getType()) { $className = 'Fab\\Media\\Thumbnail\\ImageThumbnailProcessor'; } elseif (File::FILETYPE_AUDIO == $this->file->getType()) { $className = 'Fab\\Media\\Thumbnail\\AudioThumbnailProcessor'; } elseif (File::FILETYPE_VIDEO == $this->file->getType()) { $className = 'Fab\\Media\\Thumbnail\\VideoThumbnailProcessor'; } elseif (File::FILETYPE_APPLICATION == $this->file->getType() || File::FILETYPE_TEXT == $this->file->getType()) { $className = 'Fab\\Media\\Thumbnail\\ApplicationThumbnailProcessor'; } /** @var $processorInstance \Fab\Media\Thumbnail\ThumbnailProcessorInterface */ $processorInstance = GeneralUtility::makeInstance($className); $thumbnail = ''; if ($this->file->exists()) { $thumbnail = $processorInstance->setThumbnailService($this)->create(); } else { $logger = Logger::getInstance($this); $logger->warning(sprintf('Resource not found for File uid "%s" at %s', $this->file->getUid(), $this->file->getIdentifier())); } return $thumbnail; }
/** * Force download of the file. * * @param File $file * @param bool $forceDownload * @return bool|string */ public function downloadAction(File $file, $forceDownload = FALSE) { if ($file->exists() && $file->getStorage()->isWithinFileMountBoundaries($file->getParentFolder())) { // Emit signal before downloading the file. $this->emitBeforeDownloadSignal($file); // Read the file and dump it with the flag "forceDownload" set to TRUE or FALSE. $file->getStorage()->dumpFileContents($file, $forceDownload); $result = TRUE; } else { $result = 'Access denied!'; } return $result; }