public function download($link)
    {
        $file = $this->getFile($link);

        $relPath = $this->getItemDirectory()->getRelPath($file);

        $tmpDir = rtrim(\tao_helpers_File::createTempDir(), '/');
        $tmpFile = $tmpDir . $relPath;
        if (! is_dir(dirname($tmpFile))) {
            mkdir(dirname($tmpFile), 0755, true);
        }

        if (($resource = fopen($tmpFile, 'w')) !== false) {
            stream_copy_to_stream($file->readStream(), $resource);
            fclose($resource);
            return $tmpFile;
        }

        throw new \common_Exception('Unable to write "' . $link . '" into tmp folder("' . $tmpFile . '").');
    }
public function download($link)
    {
        $file = $this->getFile($link);

        $relPath = $this->getItemDirectory()->getRelPath($file);

        $tmpDir = rtrim(\tao_helpers_File::createTempDir(), '/');
        $tmpFile = $tmpDir . $relPath;
        if (! is_dir(dirname($tmpFile))) {
            mkdir(dirname($tmpFile), 0755, true);
        }

        if (($resource = fopen($tmpFile, 'w')) !== false) {
            stream_copy_to_stream($file->readStream(), $resource);
            fclose($resource);
            return $tmpFile;
        }

        throw new \common_Exception('Unable to write "' . $link . '" into tmp folder("' . $tmpFile . '").');
    }
public function download ( $ link ) { $ file = $ this -> getFile ( $ link ) ; $ relPath = $ this -> getItemDirectory ( ) -> getRelPath ( $ file ) ; $ tmpDir = rtrim ( \ tao_helpers_File :: createTempDir ( ) , '/' ) ; $ tmpFile = $ tmpDir . $ relPath ; if ( ! is_dir ( dirname ( $ tmpFile ) ) ) { mkdir ( dirname ( $ tmpFile ) , 0755 , true ) ; } if ( ( $ resource = fopen ( $ tmpFile , 'w' ) ) !== false ) { stream_copy_to_stream ( $ file -> readStream ( ) , $ resource ) ; fclose ( $ resource ) ; return $ tmpFile ; } throw new \ common_Exception ( 'Unable to write "' . $ link . '" into tmp folder("' . $ tmpFile . '").' ) ; }
Copy file content to temp file. Path is return to be downloaded

@see \oat\tao\model\media\MediaBrowser::download
@param string $link
@return string
@throws \common_Exception
@throws \tao_models_classes_FileNotFoundException
@throws common_exception_Error
Copy file content to temp file . Path is return to be downloaded