MediaFileBundle/Controller/MediaController.php
public function getAction($key)
    {
        $mediaStorageManager = $this->get('open_orchestra_media_file.manager.storage');
        $fileContent = $mediaStorageManager->getFileContent($key);

        $finfo = finfo_open(FILEINFO_MIME);
        $mimetype = finfo_buffer($finfo, $fileContent);
        finfo_close($finfo);

        $response = new Response();
        $response->headers->set('Content-Type', $mimetype);
        $response->headers->set('Content-Length', strlen($fileContent));
        $response->setContent($fileContent);
        $response->setPublic();
        $response->setMaxAge(2629743);

        $date = new \DateTime();
        $date->modify('+'.$response->getMaxAge().' seconds');
        $response->setExpires($date);
        return $response;
    }
public function getAction($key)
    {
        $mediaStorageManager = $this->get('open_orchestra_media_file.manager.storage');
        $fileContent = $mediaStorageManager->getFileContent($key);

        $finfo = finfo_open(FILEINFO_MIME);
        $mimetype = finfo_buffer($finfo, $fileContent);
        finfo_close($finfo);

        $response = new Response();
        $response->headers->set('Content-Type', $mimetype);
        $response->headers->set('Content-Length', strlen($fileContent));
        $response->setContent($fileContent);
        $response->setPublic();
        $response->setMaxAge(2629743);

        $date = new \DateTime();
        $date->modify('+'.$response->getMaxAge().' seconds');
        $response->setExpires($date);
        return $response;
    }
public function getAction ( $ key ) { $ mediaStorageManager = $ this -> get ( 'open_orchestra_media_file.manager.storage' ) ; $ fileContent = $ mediaStorageManager -> getFileContent ( $ key ) ; $ finfo = finfo_open ( FILEINFO_MIME ) ; $ mimetype = finfo_buffer ( $ finfo , $ fileContent ) ; finfo_close ( $ finfo ) ; $ response = new Response ( ) ; $ response -> headers -> set ( 'Content-Type' , $ mimetype ) ; $ response -> headers -> set ( 'Content-Length' , strlen ( $ fileContent ) ) ; $ response -> setContent ( $ fileContent ) ; $ response -> setPublic ( ) ; $ response -> setMaxAge ( 2629743 ) ; $ date = new \ DateTime ( ) ; $ date -> modify ( '+' . $ response -> getMaxAge ( ) . ' seconds' ) ; $ response -> setExpires ( $ date ) ; return $ response ; }
Send a media stored via the UploadedFileManager

@Config\Route("/{key}", name="open_orchestra_media_get")
@Config\Method({"GET"})

@return Response
Send a media stored via the UploadedFileManager