public function fileAccessAction()
 {
     $request = $this->getRequest();
     $modifiedSince = $request->getHeader('If-Modified-Since');
     if ($modifiedSince instanceof IfModifiedSince) {
         $response = $this->getResponse();
         $response->setStatusCode(304);
         $this->cacheResponse($response);
         return $response;
     }
     $event = $this->getEvent();
     $data = $event->getParam('ZFContentNegotiationParameterData');
     $id = $data->getRouteParam('file_id');
     $forceDownload = (bool) $data->getQueryParam('download', false);
     $file = $this->repository->find($id);
     if (!$file) {
         //return new ApiProblem(404, 'No file exists');
         return $this->notFoundAction();
     }
     if ($file['type'] !== 'FILE') {
         return $this->notFoundAction();
     }
     if ($file['filesystem_error']) {
         return $this->notFoundAction();
     }
     $filesystemName = $file['filesystem'];
     $filesystem = $this->manager->get($filesystemName);
     $response = new \Zend\Http\Response\Stream();
     $response->setStream($filesystem->readStream($file['filesystem_path']));
     $response->setStatusCode(200);
     $headers = $response->getHeaders();
     $headers->addHeaderLine('Content-Type', $file['mime_type']);
     if ($forceDownload) {
         $headers->addHeaderLine('Content-Disposition', 'attachment; filename="' . $file['name'] . '"');
         //$headers->addHeaderLine('Content-Length', 7687);//$file['size']);//todo fix size
     }
     /** @var $lastModified LastModified  */
     $lastModified = new LastModified();
     $lastModified->setDate($file['create_time']);
     $headers->addHeader($lastModified);
     $this->cacheResponse($response);
     //$response->setHeaders($headers);
     return $response;
 }