public function fileAction($objectId, $fileId)
    {
        if (empty($objectId) || empty($fileId)) {
            return $this->accessDenied();
        }

        $contactClient = $this->checkContactClientAccess($objectId, 'view');
        if ($contactClient instanceof Response) {
            return $contactClient;
        }

        $file = $this->checkContactClientFileAccess($fileId, 'view');
        if ($file instanceof Response) {
            return $file;
        }

        if (!$file || !$file->getLocation() || !file_exists($file->getLocation())) {
            return $this->accessDenied();
        }

        $response = new BinaryFileResponse($file->getLocation());
        $response->setPrivate();
        $response->setContentDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT);

        return $response;
    }
public function fileAction($objectId, $fileId)
    {
        if (empty($objectId) || empty($fileId)) {
            return $this->accessDenied();
        }

        $contactClient = $this->checkContactClientAccess($objectId, 'view');
        if ($contactClient instanceof Response) {
            return $contactClient;
        }

        $file = $this->checkContactClientFileAccess($fileId, 'view');
        if ($file instanceof Response) {
            return $file;
        }

        if (!$file || !$file->getLocation() || !file_exists($file->getLocation())) {
            return $this->accessDenied();
        }

        $response = new BinaryFileResponse($file->getLocation());
        $response->setPrivate();
        $response->setContentDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT);

        return $response;
    }
public function fileAction ( $ objectId , $ fileId ) { if ( empty ( $ objectId ) || empty ( $ fileId ) ) { return $ this -> accessDenied ( ) ; } $ contactClient = $ this -> checkContactClientAccess ( $ objectId , 'view' ) ; if ( $ contactClient instanceof Response ) { return $ contactClient ; } $ file = $ this -> checkContactClientFileAccess ( $ fileId , 'view' ) ; if ( $ file instanceof Response ) { return $ file ; } if ( ! $ file || ! $ file -> getLocation ( ) || ! file_exists ( $ file -> getLocation ( ) ) ) { return $ this -> accessDenied ( ) ; } $ response = new BinaryFileResponse ( $ file -> getLocation ( ) ) ; $ response -> setPrivate ( ) ; $ response -> setContentDisposition ( ResponseHeaderBag :: DISPOSITION_ATTACHMENT ) ; return $ response ; }
Downloads a file securely.

@param null $contactClientId
@param null $fileId

@return array|\MauticPlugin\MauticContactClientBundle\Entity\ContactClient|BinaryFileResponse|\Symfony\Component\HttpFoundation\JsonResponse|\Symfony\Component\HttpFoundation\RedirectResponse

@throws \Exception
Downloads a file securely .