/**
  * @param Request $request
  * @param string $path
  * @return StreamedResponse
  */
 public function show(Request $request, $path)
 {
     $params = $request->query();
     if ($this->secure) {
         $this->validateRequest($path, $params);
         $this->validateRequest($path, $params);
     }
     return $this->server->getImageResponse($path, $params);
 }
 function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $next)
 {
     $url = $request->getAttribute('virtualUri', '');
     if (!str_beginsWith($url, "{$this->settings->fileBaseUrl()}/")) {
         return $next();
     }
     // Strip prefix from URL
     $url = substr($url, strlen($this->settings->fileBaseUrl()) + 1);
     $path = "{$this->settings->fileArchivePath()}/{$url}";
     if (!file_exists($path)) {
         return $this->responseFactory->make(404, "Not found: {$path}", 'text/plain');
     }
     $mime = FileUtil::getMimeType($path);
     // Serve image file.
     if (FileUtil::isImageType($mime)) {
         // Use image manipulation parameters extracted from the request.
         return $this->glideServer->getImageResponse($url, $request->getQueryParams());
     }
     // Server non-image file.
     return $this->responseFactory->makeStream(fopen($path, 'rb'), 200, ['Content-Type' => $mime, 'Content-Length' => (string) filesize($path), 'Cache-Control' => 'max-age=31536000, public', 'Expires' => date_create('+1 years')->format('D, d M Y H:i:s') . ' GMT']);
 }
 public static function getPhoto(Server $server, Request $request, $id, $file)
 {
     $photo_file = $file;
     $path = "project/{$id}/photo/{$photo_file}";
     return $server->getImageResponse($path, $_GET);
 }
Exemple #4
0
 /**
  * {@inheritdoc}
  */
 public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = true)
 {
     return $this->server->getImageResponse($request);
 }