canServedLocal example


    public function send(string $location, FilesystemInterface $filesystem): void
    {
        $this->front->Plugins()->ViewRenderer()->setNoRender();
        $downloadStrategy = (int) $this->config->get('esdDownloadStrategy');

        $meta = $filesystem->getMetadata($location);
        $mimeType = $filesystem->getMimetype($location) ?: 'application/octet-stream';

        $response = $this->front->Response();

        if ($this->canServedLocal($filesystem$downloadStrategy)) {
            $publicUrl = $this->publicUrlGenerator->generateUrl($location);
            $path = (string) parse_url($publicUrl, PHP_URL_PATH);
            switch ($downloadStrategy) {
                case 0:
                    $response->setRedirect($publicUrl);
                    break;
                case 2:
                    $location = $this->privateFilesystemRoot . '/' . $location;
                    $response->headers->set('content-type', 'application/octet-stream');
                    $response->headers->set('content-disposition', sprintf('attachment; filename="%s"', basename($location)));
                    $response->headers->set('x-sendfile', $location);
                    
Home | Imprint | This part of the site doesn't use cookies.