General developer forum

web service core_files_upload, The file has not been specified

 
Picture of Carlos H Bolaños
web service core_files_upload, The file has not been specified
 

Moodle version 3.3


Best regard,


I have configured the REST web service.


he made tests with core_course_get_courses and everything perfect, if you list me. BUT when I use core_files_upload with its required arguments (context, component, file area, itemid, file path, file name, file content, context level, instanceid)


He throws me the following, but does not look for solutions or examples.


"exception": "moodle_exception",


"errorcode": "nofile",


"message": "The file has not been specified"


 
Average of ratings: -
Picture of Patrick Liersch
Re: web service core_files_upload, The file has not been specified
 

I am at the same Situation and need a solution.

We want to use the core_files_upload API for manage the User Profil Picture on a User Management.

array(9) {
  ["contextid"]=>
  int(31)
  ["component"]=>
  string(4) "user"
  ["filearea"]=>
  string(5) "draft"
  ["itemid"]=>
  int(0)
  ["filepath"]=>
  string(1) "/"
  ["filename"]=>
  string(6) "avatar.png"
  ["filecontent"]=>
  string(14172) "/9j/4AAQSkZJRgA....." (BASE64)
  ["contextlevel"]=>
  string(4) "user"
  ["instanceid"]=>
  string(1) "5"
}
Answer: "nofile The file has not been specified "

Contextid of the User with Instance ID (UserID) and Contextlevel = 30

 
Average of ratings: -
Picture of Patrick Liersch
Re: web service core_files_upload, The file has not been specified
 

I think the problem is the File API

Function "upload" (files/externallib.php)

if ($dir = $browser->get_file_info($context, $component, $filearea, $itemid, $filepath, '.')) {


That is ever "false" - but the File is correct in the temp Path "moodledata/temp" (why not temp/wsupload ?)

Input from $context, $component, $filearea, $itemid, $filepath

object(context_user)#132 (5) {
  ["_id":protected]=>
  int(31)
  ["_contextlevel":protected]=>
  int(30)
  ["_instanceid":protected]=>
  string(1) "5"
  ["_path":protected]=>
  string(5) "/1/31"
  ["_depth":protected]=>
  string(1) "2"
}
string(4) "user"
string(5) "draft"
int(52815862)
string(1) "/"


Tested on: 3.4+ (Build: 20171208)

 
Average of ratings: -