/** * @param null|string $mimeType * @throws NotFoundException */ public function showPreview($mimeType = null) { // Check if file is valid if ($this->isFileValid() === false) { throw new NotFoundException('File not found.'); } \OCP\Response::enableCaching(3600 * 24); // 24 hours if (is_null($this->preview)) { $this->getPreview(); } if ($this->preview instanceof \OCP\IImage) { $this->preview->show($mimeType); } }
/** * Sends the preview, including the headers to client which requested it * * @param null|string $mimeTypeForHeaders the media type to use when sending back the reply * * @throws NotFoundException */ public function showPreview($mimeTypeForHeaders = null) { // Check if file is valid if ($this->isFileValid() === false) { throw new NotFoundException('File not found.'); } if ($cachedPath = $this->isCached($this->info->getId())) { header('Content-Type: ' . $this->info->getMimetype()); $this->userView->readfile($cachedPath); return; } if (is_null($this->preview)) { $this->getPreview(); } if ($this->preview instanceof \OCP\IImage) { if ($this->preview->valid()) { \OCP\Response::enableCaching(3600 * 24); // 24 hours } else { $this->getMimeIcon(); } $this->preview->show($mimeTypeForHeaders); } }