public function downloadMediaAction($filename)
    {
        $media = $this->mediaManager->getRepository()->findOneByReference($filename);
        $provider = $this->container->get('opifer.media.provider.pool')->getProvider($media->getProvider());

        $mediaUrl = $provider->getUrl($media);

        $fileSystem = $provider->getFileSystem();
        $file = $fileSystem->read($media->getReference());
        
        $response = new Response();
        $response->headers->set('Content-type', $media->getContentType());
        $response->headers->set('Content-Disposition', sprintf('attachment; filename="%s"', basename($mediaUrl)));
        $response->setContent($file);
        
        return $response;
    }
public function downloadMediaAction($filename)
    {
        $media = $this->mediaManager->getRepository()->findOneByReference($filename);
        $provider = $this->container->get('opifer.media.provider.pool')->getProvider($media->getProvider());

        $mediaUrl = $provider->getUrl($media);

        $fileSystem = $provider->getFileSystem();
        $file = $fileSystem->read($media->getReference());
        
        $response = new Response();
        $response->headers->set('Content-type', $media->getContentType());
        $response->headers->set('Content-Disposition', sprintf('attachment; filename="%s"', basename($mediaUrl)));
        $response->setContent($file);
        
        return $response;
    }
public function downloadMediaAction ( $ filename ) { $ media = $ this -> mediaManager -> getRepository ( ) -> findOneByReference ( $ filename ) ; $ provider = $ this -> container -> get ( 'opifer.media.provider.pool' ) -> getProvider ( $ media -> getProvider ( ) ) ; $ mediaUrl = $ provider -> getUrl ( $ media ) ; $ fileSystem = $ provider -> getFileSystem ( ) ; $ file = $ fileSystem -> read ( $ media -> getReference ( ) ) ; $ response = new Response ( ) ; $ response -> headers -> set ( 'Content-type' , $ media -> getContentType ( ) ) ; $ response -> headers -> set ( 'Content-Disposition' , sprintf ( 'attachment; filename="%s"' , basename ( $ mediaUrl ) ) ) ; $ response -> setContent ( $ file ) ; return $ response ; }
Download media item.

@param string $filename

@return Response
Download media item .