Error downloading large files [ Moodle 2.2.1+ (Build: 20120119) ]

Error downloading large files [ Moodle 2.2.1+ (Build: 20120119) ]

by Alberto Nieto -
Number of replies: 3

I found a really strange behaviour on my moodle site.


I am able to upload large files on the site. If I attach them on a post, I can download them normally. If I upload them as a resource of a course, I can only download them if they are less than 20MB or so. If I try to download a large file uploaded as a resource of a course, I get the following error on my browser: ERR_INVALID_RESPONSE


The files from a post have this kind of URLhttp://mymoodlesite.org/pluginfile.php/920/mod_forum/attachment/1846/largeFileName.pdf

The files from a course have this kind of URL: http://mymoodlesite.org/pluginfile.php/222/mod_source/file/41/0/largeFileName.pdf

Average of ratings: -
In reply to Alberto Nieto

Re: Error downloading large files [ Moodle 2.2.1+ (Build: 20120119) ]

by Matteo Scaramuccia -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers

Hi Alberto,
are you sure about mod_source in your URL? Is yours a plain Moodle site i.e. no plug-ins and no core code changes? Are those URLs generated by Moodle or cut&pasted by someone from something for some reason?

I bet it is a typo i.e. it should be mod_resource: in this case, file is wrong, it should be content. Besides 41/0 should be just 0.

TIA,
Matteo

In reply to Matteo Scaramuccia

Re: Error downloading large files [ Moodle 2.2.1+ (Build: 20120119) ]

by Alberto Nieto -

Hi Matteo,


Thanks for answering. The url is correct and not copy pasted, however we are running a strongly modified moodle site, so it may happen that some added plugin or change on the core is generating this url instead of the default one you mentioned above.

In reply to Alberto Nieto

Re: Error downloading large files [ Moodle 2.2.1+ (Build: 20120119) ]

by Alberto Nieto -

I found this piece of code that may be related, however it works fine for small files:


class oussource_file extends ousbase_file {

    

    static protected $_type = 'source_file';


    static public function get_document($document) {

        global $DB, $CFG;

        $group_ids = self::get_group_ids();

        $post = $DB->get_record_sql("SELECT f.*,sf.*,(sf.group_id NOT IN ($group_ids)) AS hide FROM {files} f

            INNER JOIN {source_file} sf ON (f.id=sf.files_id)

            WHERE f.id=?", array('id' => $document->intref1));

        if ($post->filename == '.') { return false; } // MIND U: removes result from DB

        

        if (!$post) { return false; }

        $result = (object)array(

            'hide' => $post->hide,

            'content' => $post->filename . ' - ' . self::_filesize($post->filesize) . ' ' . $post->description,

            'title' => self::title_prefix('source_file') . $post->filename,

            'url' => $CFG->wwwroot . sprintf('/pluginfile.php/%d/mod_source/file/%d/%d/%s', 

                $post->contextid, $post->group_id, $post->path_id, $post->filename),

            'activityname' => 'Source file',

            'activityurl' => '#',

            'data' => $post

        );

        return $result;

    }


    static public function update($post, $cm=null) {


        $doc = self::get_search_document($post, $cm);

    

        // Update information about this post (works ok for add or edit)

        $doc->update($post->filename, $post->description, time());

        return true;

        

    }

    

}