Example #1
0
 /**
  * Gibt das Vorschaubild eines Screenshots aus
  */
 public function getscreenAction()
 {
     $validatedRequest = $this->getValidatedRequest('Cdn', 'GetScreen', true);
     if ($validatedRequest === false) {
         return;
     }
     $screenStreamFilePath = $this->getBusiness()->getScreenStreamFilePath($validatedRequest->getWebsiteId(), $validatedRequest->getId(), $validatedRequest->getType(), array('width' => $validatedRequest->getWidth(), 'height' => $validatedRequest->getHeight()));
     if (empty($screenStreamFilePath) || !file_exists($screenStreamFilePath)) {
         $screenStreamFilePath = $this->getBusiness()->getDefaultScreenshot();
         $this->getResponse()->setHttpResponseCode(404);
     }
     $screenFileName = $this->getBusiness()->getScreenFileName($validatedRequest->getId(), $validatedRequest->getType());
     $response = $this->getResponse();
     $response->setHeader('Content-Type', Mimetype::getMimetype($screenStreamFilePath));
     $response->setHeader('Cache-Control', 'max-age=0, must-revalidate, private');
     $response->setHeader('Content-Disposition', 'inline; filename="' . $screenFileName . '"');
     $response->setOutputBodyCallback(function ($response, $chunkSize) use($screenStreamFilePath) {
         if (is_file($screenStreamFilePath) && is_readable($screenStreamFilePath)) {
             $fd = fopen($screenStreamFilePath, 'rb');
             if ($fd !== false) {
                 while (!feof($fd) && !connection_aborted()) {
                     print fread($fd, $chunkSize);
                     $response->flushOutput();
                 }
                 fclose($fd);
             }
         }
     });
 }
Example #2
0
 /**
  * @param $fileName
  *
  * @return string
  */
 protected function getMimeType($fileName)
 {
     return \Seitenbau\Mimetype::getMimetype($fileName);
 }