'', 'message' => '' ]; } /** @var CanRenderDocument */ private $canRenderDocument; /** @var JWT */ private $manager; /** * RenderDocumentLogic constructor. * @param CanRenderDocument $canRenderDocument * @param JWT $manager */ public function __construct(CanRenderDocument $canRenderDocument, JWT $manager) { $this->canRenderDocument = $canRenderDocument; $this->manager = $manager; } /** * @param Request $request * @return JsonResponse * @throws AccessForbiddenException * @throws RequestValidationException * @throws ResourceNotFoundException * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException */ public function logic(Request $request) : JsonResponse { $file = $request->route('fileName'); $this->canRenderDocument->passes(); if(!Storage::disk('documents')->exists($file)) { throw new ResourceNotFoundException(); } $extention = explode('.', $file); if ($extention[1] == 'pdf') { return $this->response(['src' => chunk_split(base64_encode(Storage::disk('documents')->get($file)))]); } else { return $this->response(['src' => Storage::disk('documents')->get($file)]); } } }