/** * @param Request $request * @param \SplFileInfo $file * @param string $contentType * @return BinaryFileResponse */ private function createBinaryFileResponse(Request $request, \SplFileInfo $file, $contentType) { $response = new BinaryFileResponse($file, Response::HTTP_OK, array('Content-Type' => $contentType), true, null, true, true); if ($response->isNotModified($request)) { return $response; } return $response; }
protected function openFile(Request $request, FileManager $fileManager) { if (!$request->query->has('path')) { return $this->abort(400); } $path = $fileManager->getAbsolutePath($request->query->get('path')); if (!is_file($path)) { return $this->abort(404); } $response = new BinaryFileResponse($path, 200, ["Content-Disposition" => ' inline; filename="' . pathinfo($path, PATHINFO_BASENAME) . '"'], null, true); if (!$response->isNotModified($request)) { set_time_limit(0); } return $response; }