src/Entity/XiboLibrary.php
public function download($mediaId, $type, $filePath, $fileName)
    {
        $this->mediaId = $mediaId;
        $this->mediaType = $type;

        $this->getLogger()->info('Downloading media ID ' . $mediaId . ' and saving it in ' . $filePath . ' as ' . $fileName);
        $response = $this->doGet('/library/download/' . $this->mediaId . '/' . $this->mediaType);

        // Check if the directory exists, if not create it
        $this->getLogger()->debug('Checking if the directory exists');
        if (!file_exists($filePath)) {
            $this->getLogger()->debug('Creating directory to save files to ' . $filePath);
            mkdir($filePath, 0777, true);
        }
        // Save file to the directory with the provided name
        $file = fopen($filePath . $fileName, 'w');
        fwrite($file, $response);
        fclose($file);


        return true;
    }
public function download($mediaId, $type, $filePath, $fileName)
    {
        $this->mediaId = $mediaId;
        $this->mediaType = $type;

        $this->getLogger()->info('Downloading media ID ' . $mediaId . ' and saving it in ' . $filePath . ' as ' . $fileName);
        $response = $this->doGet('/library/download/' . $this->mediaId . '/' . $this->mediaType);

        // Check if the directory exists, if not create it
        $this->getLogger()->debug('Checking if the directory exists');
        if (!file_exists($filePath)) {
            $this->getLogger()->debug('Creating directory to save files to ' . $filePath);
            mkdir($filePath, 0777, true);
        }
        // Save file to the directory with the provided name
        $file = fopen($filePath . $fileName, 'w');
        fwrite($file, $response);
        fclose($file);


        return true;
    }
public function download ( $ mediaId , $ type , $ filePath , $ fileName ) { $ this -> mediaId = $ mediaId ; $ this -> mediaType = $ type ; $ this -> getLogger ( ) -> info ( 'Downloading media ID ' . $ mediaId . ' and saving it in ' . $ filePath . ' as ' . $ fileName ) ; $ response = $ this -> doGet ( '/library/download/' . $ this -> mediaId . '/' . $ this -> mediaType ) ; // Check if the directory exists, if not create it $ this -> getLogger ( ) -> debug ( 'Checking if the directory exists' ) ; if ( ! file_exists ( $ filePath ) ) { $ this -> getLogger ( ) -> debug ( 'Creating directory to save files to ' . $ filePath ) ; mkdir ( $ filePath , 0777 , true ) ; } // Save file to the directory with the provided name $ file = fopen ( $ filePath . $ fileName , 'w' ) ; fwrite ( $ file , $ response ) ; fclose ( $ file ) ; return true ; }
Download Media from CMS library.

@param int $mediaId The media ID to download
@param string $type The module type to download
@param string $filePath Path to the directory where files should be saved
@param string $fileName Name of the saved media file
@return boolean
Download Media from CMS library .