<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
	<id>http://wiki.mipt.ru/index.php?action=history&amp;feed=atom&amp;title=Development%3AWeb_services%3AFiles</id>
	<title>Development:Web services:Files - История изменений</title>
	<link rel="self" type="application/atom+xml" href="http://wiki.mipt.ru/index.php?action=history&amp;feed=atom&amp;title=Development%3AWeb_services%3AFiles"/>
	<link rel="alternate" type="text/html" href="http://wiki.mipt.ru/index.php?title=Development:Web_services:Files&amp;action=history"/>
	<updated>2026-05-08T01:48:19Z</updated>
	<subtitle>История изменений этой страницы в вики</subtitle>
	<generator>MediaWiki 1.42.1</generator>
	<entry>
		<id>http://wiki.mipt.ru/index.php?title=Development:Web_services:Files&amp;diff=12142&amp;oldid=prev</id>
		<title>Олег Давидович: 1 версия импортирована</title>
		<link rel="alternate" type="text/html" href="http://wiki.mipt.ru/index.php?title=Development:Web_services:Files&amp;diff=12142&amp;oldid=prev"/>
		<updated>2024-10-21T08:53:26Z</updated>

		<summary type="html">&lt;p&gt;1 версия импортирована&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Предыдущая версия&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Версия от 08:53, 21 октября 2024&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Олег Давидович</name></author>
	</entry>
	<entry>
		<id>http://wiki.mipt.ru/index.php?title=Development:Web_services:Files&amp;diff=12141&amp;oldid=prev</id>
		<title>1&gt;Dongsheng в 07:50, 9 июля 2010</title>
		<link rel="alternate" type="text/html" href="http://wiki.mipt.ru/index.php?title=Development:Web_services:Files&amp;diff=12141&amp;oldid=prev"/>
		<updated>2010-07-09T07:50:40Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;These APIs will be used to browse Moodle files by Moodle Web Services.&lt;br /&gt;
&lt;br /&gt;
===class moodle_file_external()===&lt;br /&gt;
&lt;br /&gt;
This class implements the interface to moodle files, for browsing, downloading and uploading files.  It is defined in files/externals.php.&lt;br /&gt;
&lt;br /&gt;
We cannot return the whole files tree by web service API, because to make sure the web services working in every language and platform, we need to define a fixed data structure of return value, but the files tree can change all the time. See more information about web services at: [[Development:External_services_description]].&lt;br /&gt;
&lt;br /&gt;
The class contains following methods:&lt;br /&gt;
&lt;br /&gt;
====get_files====&lt;br /&gt;
This function is used to browse files.&lt;br /&gt;
&lt;br /&gt;
It takes 5 parameters, all of them are optional, if you provide no parameters, it will return the top level content of moodle repository.&lt;br /&gt;
&lt;br /&gt;
* contextid&lt;br /&gt;
* component&lt;br /&gt;
* filearea&lt;br /&gt;
* itemid&lt;br /&gt;
* filename&lt;br /&gt;
* filepath&lt;br /&gt;
&lt;br /&gt;
It will return an array, can be described as PHP array:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$files = array(&lt;br /&gt;
  &amp;#039;path&amp;#039; =&amp;gt; array(array(&amp;#039;name&amp;#039;=&amp;gt;&amp;#039;root&amp;#039;, &amp;#039;path=&amp;gt;&amp;#039;/&amp;#039;), array(&amp;#039;name&amp;#039;=&amp;gt;&amp;#039;subdir&amp;#039;, &amp;#039;path=&amp;gt;&amp;#039;/sub/&amp;#039;)),&lt;br /&gt;
  &amp;#039;files&amp;#039; =&amp;gt; array(&lt;br /&gt;
       array(&amp;#039;filename&amp;#039;=&amp;gt;&amp;#039;readme&amp;#039;, &amp;#039;filepath&amp;#039;=&amp;gt;&amp;#039;/&amp;#039;, &amp;#039;filearea&amp;#039;=&amp;gt;&amp;#039;forum&amp;#039;, &amp;#039;itemid&amp;#039;=&amp;gt;110, &amp;#039;contextid&amp;#039;=&amp;gt;1, &amp;#039;isdir&amp;#039;=&amp;gt;true),&lt;br /&gt;
       array(&amp;#039;filename&amp;#039;=&amp;gt;&amp;#039;changes&amp;#039;, &amp;#039;filepath&amp;#039;=&amp;gt;&amp;#039;/&amp;#039;, &amp;#039;filearea&amp;#039;=&amp;gt;&amp;#039;forum&amp;#039;, &amp;#039;itemid&amp;#039;=&amp;gt;112, &amp;#039;contextid&amp;#039;=&amp;gt;1, &amp;#039;isdir&amp;#039;=&amp;gt;false),&lt;br /&gt;
     )&lt;br /&gt;
);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The service name is &amp;quot;moodle_file_get_files&amp;quot;, defined in lib/db/services.php.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====upload====&lt;br /&gt;
This function is used to upload a file to user private area.&lt;br /&gt;
&lt;br /&gt;
It takes 7 parameters, all of them are mandatory:&lt;br /&gt;
&lt;br /&gt;
* contextid&lt;br /&gt;
* component&lt;br /&gt;
* filearea&lt;br /&gt;
* itemid&lt;br /&gt;
* filepath&lt;br /&gt;
* filename&lt;br /&gt;
* filecontent&lt;br /&gt;
&lt;br /&gt;
It will return a boolean value, true/false.&lt;br /&gt;
&lt;br /&gt;
The service name is &amp;quot;moodle_file_upload&amp;quot;, defined in lib/db/services.php&lt;br /&gt;
&lt;br /&gt;
Sample code (using Zend Framework):&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$url = MOODLE_WSROOT. &amp;#039;?wstoken=xxxxxxxxxxxxxxxxxxxxxx&amp;#039;;&lt;br /&gt;
$zend = new Zend_XmlRpc_Client($url);&lt;br /&gt;
$srv = $zend-&amp;gt;getProxy();&lt;br /&gt;
$files = $srv-&amp;gt;moodle_file_get_files($contextid, $component, $filearea, $itemid, $filepath, $filename);&lt;br /&gt;
$file = $srv-&amp;gt;moodle_file_upload($contextid, &amp;#039;user&amp;#039;, &amp;#039;private&amp;#039;, 0, &amp;#039;/&amp;#039;, &amp;#039;info.txt&amp;#039;, base64_encode(&amp;#039;this is file content&amp;#039;));&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>1&gt;Dongsheng</name></author>
	</entry>
</feed>