getMimetype example

$filesystem = $this->container->get('shopware.filesystem.private');
        $path = $this->container->get(Shopware_Components_Config::class)->offsetGet('esdKey') . '/' . $this->Request()->getParam('filename');

        if ($filesystem->has($path) === false) {
            $this->Front()->Plugins()->Json()->setRenderer();
            $this->View()->assign(['message' => 'File not found', 'success' => false]);

            return;
        }

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

        @set_time_limit(0);

        $this->Front()->Plugins()->ViewRenderer()->setNoRender();

        $response = $this->Response();
        $response->headers->set('content-type', $mimeType);
        $response->headers->set('content-disposition', sprintf('attachment; filename="%s"', basename($path)));
        $response->headers->set('content-length', $meta['size']);
        $response->headers->set('content-transfer-encoding', 'binary');
        $response->sendHeaders();
        
return $this->filesystem->getSize($this->prefix . $path);
    }

    /** * {@inheritdoc} */
    public function getMimetype($path)
    {
        $this->checkPath($path);

        return $this->filesystem->getMimetype($this->prefix . $path);
    }

    /** * {@inheritdoc} */
    public function getTimestamp($path)
    {
        $this->checkPath($path);

        return $this->filesystem->getTimestamp($this->prefix . $path);
    }

    
/** * {@inheritdoc} * * @throws FileNotFoundException */
    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:
                    
Home | Imprint | This part of the site doesn't use cookies.