Error code: storedfilecannotread

Error code: storedfilecannotread

by A Guy -
Number of replies: 0

I wrote a plugin that uses Moodle's zip_archive class to create a zip file and write files stored in Moodle's file repo to it. Here is a snippet:


    $zip = new zip_archive;
    $zipfilename=$USER->id."_$today.zip";
  
    $zip->open($CFG->tempdir."/$zipfilename");


The zip file is obviously written to the tempdir in moodledata.

The file gets created just fine.

However, the problem is that when I go to try and store it for real in the Moodle filerepo in order to get a URL back out of Moodle for the user to download the file I get the "Storedfilecannotberead" error.


I get this with

create_file_from_pathname($file_record, $CFG->tempdir."/$zipfilename");

and

$fs->add_file_to_pool($CFG->tempdir."/$zipfilename");


I think it is a Linux group problem. But Moodle creates backups with the zippacker with no issues in moodledata/the moodle repo. So I'm confused. THe file is 0644. But I cannot tell who owns it as this is a shared server and I cannot see those details. I cannot chown/chmod it. I cannot stat it. So without any other info I cannot figure out how to fix this. Sounds to me like the apache user and the php user are not in the same group. With the file being 644 looks like if they were in the same group the two commands above would work as the file could be read.


Any thoughts?

Average of ratings: -