I am trying to develop a client for android . How should I download a file resource who belongs to a course ? should I use the web services API core_files_get_files ? If so , what is the parameter context id?
any help is appreciated.
I am using the REST .
I also read your other post about trying to use SOAP for webservice on mobile. Dont do that! My experience in developing moodle for mobile with SOAP was cancelled release due to slow execution.
thanks very much . That I am trying to do is to get files, so I should pass a context id to the web server , not to find the context id in the DB . I am really confused. Hope you can explain this to me .
thanks . I have read the docs . But I am using java-rest. so I didn't quite understand the PHP. can you explain the parameter to me and how I can get it ?
sorry for my bad English . I can't make myself clear . I am just trying to upload a file using java-rest . like I said , I am developing a client for android phones , so I want the client be able to upload the assignments and download file in the course . How can I make it using web services ?
thanks for your patience .
Moodle upload/download file process is the common standard way in HTTP. The Moodle upload script works like when a script receives a file from a input html file tag. And the Moodle download script serves the file.
It's just about knowing the right url to call which is demonstrated into the PHP upload/download sample demo.
I hope it's enough clue to make you start finding information on Google.
I don't plan to write a Java version of Upload/download sample demo yet, but if many people request it in a tracker issue, I'l consider it However the quickest way would be that a Java developer comes up with a basic upload/download sample demo client. I'll be happy to test it and push it to the current demo client repository.
See the thread I just started. I'm nearing completing my Java library using REST protocols, the last calls to implement, apart from doing error checking and documentation, are the file ones. My problem is in the externallib.php file it shows the keys for the parameter array to be passed but there is no name for the array itself.
Ignoring the authentication and the function call name, what would be the layout within the REST call for the parameters?
Or are the parameters being expected to be passed as a HTTP POST rather than GET?
By the way, this new library will eventually update the one on Sourceforge (MoodleREST).
Sorry, ignore the POST/GET, I'm using POST in all my calls, havn't looked at that code for some time.
The externallib.php doesn't show some of the parameters as optional despite they are set to null if absent in the function and if the contextid is absent it is set to the system context id. I've tried just passing the token and webservice function name only but it still comes back with an invalid parameter message.
Hmm.... Looking at the on-line documentation all parameters are required despite defaults being chosen to fill the gaps within the function itself.
I'm using REST getting course data and after the files references, like this:
The returns is a JSON like this:
Look than the contents property is an array of itens. Each object in the array have a type property that indentifies if is a file or not.
The fileurl property is the url for download, but is necessary append the token parameter at the end of URL, like this: