public function send_file($storedfile, $lifetime=null , $filter=0, $forcedownload=false, array $options = null) {
        $reference = $this->unpack_reference($storedfile->get_reference());

        $maxcachesize = $this->max_cache_bytes();
        if (empty($maxcachesize)) {
            // Always cache the file, regardless of size.
            $cachefile = true;
        } else {
            // Size available. Only cache if it is under maxcachesize.
            $cachefile = $storedfile->get_filesize() < $maxcachesize;
        }

        if (!$cachefile) {
            \core\session\manager::write_close();
            header('Location: ' . $this->get_file_download_link($reference->url));
            die;
        }

        try {
            $this->import_external_file_contents($storedfile, $this->max_cache_bytes());
            if (!is_array($options)) {
                $options = array();
            }
            $options['sendcachedexternalfile'] = true;
            \core\session\manager::write_close();
            send_stored_file($storedfile, $lifetime, $filter, $forcedownload, $options);
        } catch (moodle_exception $e) {
            // Redirect to Dropbox, it will show the error.
            // Note: We redirect to Dropbox shared link, not to the download link here!
            \core\session\manager::write_close();
            header('Location: ' . $reference->url);
            die;
        }
    }
public function send_file($storedfile, $lifetime=null , $filter=0, $forcedownload=false, array $options = null) {
        $reference = $this->unpack_reference($storedfile->get_reference());

        $maxcachesize = $this->max_cache_bytes();
        if (empty($maxcachesize)) {
            // Always cache the file, regardless of size.
            $cachefile = true;
        } else {
            // Size available. Only cache if it is under maxcachesize.
            $cachefile = $storedfile->get_filesize() < $maxcachesize;
        }

        if (!$cachefile) {
            \core\session\manager::write_close();
            header('Location: ' . $this->get_file_download_link($reference->url));
            die;
        }

        try {
            $this->import_external_file_contents($storedfile, $this->max_cache_bytes());
            if (!is_array($options)) {
                $options = array();
            }
            $options['sendcachedexternalfile'] = true;
            \core\session\manager::write_close();
            send_stored_file($storedfile, $lifetime, $filter, $forcedownload, $options);
        } catch (moodle_exception $e) {
            // Redirect to Dropbox, it will show the error.
            // Note: We redirect to Dropbox shared link, not to the download link here!
            \core\session\manager::write_close();
            header('Location: ' . $reference->url);
            die;
        }
    }
public function send_file ( $ storedfile , $ lifetime = null , $ filter = 0 , $ forcedownload = false , array $ options = null ) { $ reference = $ this -> unpack_reference ( $ storedfile -> get_reference ( ) ) ; $ maxcachesize = $ this -> max_cache_bytes ( ) ; if ( empty ( $ maxcachesize ) ) { // Always cache the file, regardless of size. $ cachefile = true ; } else { // Size available. Only cache if it is under maxcachesize. $ cachefile = $ storedfile -> get_filesize ( ) < $ maxcachesize ; } if ( ! $ cachefile ) { \ core \ session \ manager :: write_close ( ) ; header ( 'Location: ' . $ this -> get_file_download_link ( $ reference -> url ) ) ; die ; } try { $ this -> import_external_file_contents ( $ storedfile , $ this -> max_cache_bytes ( ) ) ; if ( ! is_array ( $ options ) ) { $ options = array ( ) ; } $ options [ 'sendcachedexternalfile' ] = true ; \ core \ session \ manager :: write_close ( ) ; send_stored_file ( $ storedfile , $ lifetime , $ filter , $ forcedownload , $ options ) ; } catch ( moodle_exception $ e ) { // Redirect to Dropbox, it will show the error. // Note: We redirect to Dropbox shared link, not to the download link here! \ core \ session \ manager :: write_close ( ) ; header ( 'Location: ' . $ reference -> url ) ; die ; } }
Repository method to serve the referenced file.

@inheritDocs
Repository method to serve the referenced file .