General developer forum

Accessing files that were stored by another plugin

Picture of niels seidel
Accessing files that were stored by another plugin

I am writing my first plugins that enable users to define collections of videos for specific assignments. The videos in use should be re-used by multiple video collections in different courses. For that purposes I have written two different plugins. One for the video collections and another one for storing videos including specific metadata.

Right now I get stuck at the point where I try to make a file url inside the collection by selecting a file that was stored by the other plugin:

// get a file for a known hash:
$file = $fs->get_file_by_hash('0e344ee7266fb1bf9739fff7029159ee72154949');

// retrieve the URL
$url = moodle_url::make_pluginfile_url(

On client side the webservcie returns an error message that is not much self explaining imo:

Object { message: "Invalid response value detected", errorcode: "invalidresponse", backtrace: "* line 424 of /lib/externallib.php: invalid_response_exception thrown\n* line 233 of /lib/externallib.php: call to external_api::clean_returnvalue()\n* line 59 of /lib/ajax/service.php: call to external_api::call_external_function()\n", link: "http://localhost/moodle/", moreinfourl: "", debuginfo: "data => Invalid response value detected: Scalar type expected, array or object received.\nError code: invalidresponse" }

Is there a workaround like setting up the access.php in the right way or by telling the plugins that they are tiddly related?

I am really just looking for a good workaround, because the plugins will be deployed on a system that is dedicated for the video collections.

Average of ratings: -