No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

xep-0135.xml 29KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560
  1. <?xml version='1.0' encoding='UTF-8'?>
  2. <!DOCTYPE xep SYSTEM 'xep.dtd' [
  3. <!ENTITY % ents SYSTEM 'xep.ent'>
  4. %ents;
  5. ]>
  6. <?xml-stylesheet type='text/xsl' href='xep.xsl'?>
  7. <xep>
  8. <header>
  9. <title>File Sharing</title>
  10. <abstract>This document specifies a simple extension to existing protocols for file sharing over Jabber/XMPP.</abstract>
  11. &LEGALNOTICE;
  12. <number>0135</number>
  13. <status>Deferred</status>
  14. <type>Standards Track</type>
  15. <sig>Standards</sig>
  16. <dependencies>
  17. <spec>XMPP Core</spec>
  18. <spec>XEP-0030</spec>
  19. <spec>XEP-0096</spec>
  20. </dependencies>
  21. <supersedes/>
  22. <supersededby/>
  23. <shortname>files</shortname>
  24. &stpeter;
  25. <revision>
  26. <version>0.1</version>
  27. <date>2004-06-04</date>
  28. <initials>psa</initials>
  29. <remark>Initial version.</remark>
  30. </revision>
  31. </header>
  32. <section1 topic='Introduction' anchor='intro'>
  33. <p>Existing Jabber protocols provide a strong foundation for the controlled, permissions-based sharing of files between Jabber entities, e.g., to enable shared workspaces among ad-hoc workgroups and the attachment of files to &xep0045; rooms.</p>
  34. <p>This document defines several additional building blocks (a simple request protocol along with well-known service discovery nodes) that tie together existing protocols to enable the sharing of files between Jabber entities.</p>
  35. </section1>
  36. <section1 topic='Requirements' anchor='reqs'>
  37. <ol>
  38. <li>Enable a requesting entity to find files shared by an offering entity without depending on third parties (such as &xep0060; services or dedicated <link url="#hosting">file-hosting services</link>) (REQUIRED).</li>
  39. <li>Enable a requesting entity to discover detailed file information (OPTIONAL).</li>
  40. <li>Enable a requesting entity to ask for files shared by an offering entity (REQUIRED).</li>
  41. <li>Re-use existing Jabber/XMPP protocols wherever possible.</li>
  42. </ol>
  43. </section1>
  44. <section1 topic='Assumptions' anchor='assumptions'>
  45. <p>The protocol defined herein assumes that the offering entity is the file owner. The primary reason for this approach is that most likely the file owner (e.g., a chatroom or end user) knows best which files are available and which requesting entities have permission to view which files. Furthermore, for the purposes of this protocol it is unnecessary to assume that dedicated file-hosting services will exist on the Jabber network or that existing Jabber servers will offer file-hosting functionality (though see the <link url="#hosting">File-Hosting Services</link> section of this document).</p>
  46. </section1>
  47. <section1 topic='Discovering Support and Address of Offering Entity' anchor='disco'>
  48. <section2 topic='Offering Entity is File Owner' anchor='disco-owner'>
  49. <p>If an entity directly supports the protocol defined herein, it SHOULD include a feature of "http://jabber.org/protocol/files" in its response to a &xep0030; information request. The protocol flow is shown in the following example (an end user querying a chatroom):</p>
  50. <example caption='User Queries a Room Regarding Support'><![CDATA[
  51. <iq type='get'
  52. from='hag66@shakespeare.lit/pda'
  53. to='darkcave@macbeth.shakespeare.lit'
  54. id='disco1'>
  55. <query xmlns='http://jabber.org/protocol/disco#info'/>
  56. </iq>
  57. ]]></example>
  58. <example caption='Room Returns Info'><![CDATA[
  59. <iq type='result'
  60. from='darkcave@macbeth.shakespeare.lit'
  61. to='hag66@shakespeare.lit/pda'
  62. id='disco3'>
  63. <query xmlns='http://jabber.org/protocol/disco#info'>
  64. ...
  65. <feature var='http://jabber.org/protocol/files'/>
  66. ...
  67. </query>
  68. </iq>
  69. ]]></example>
  70. <p>This document stipulates that communications regarding files MUST occur by sending stanzas to the well-known service discovery node "files" (or sub-nodes thereof as defined below). Therefore, even if (as in the foregoing example) the file owner directly supports the protocol defined herein, the requesting entity MUST send subsequent file-related service discovery requests to the node "files" (or sub-nodes thereof). The file owner also SHOULD list that node in its response to a service discovery items request, as shown in the following example:</p>
  71. <example caption='User Queries a Room Regarding Items'><![CDATA[
  72. <iq type='get'
  73. from='hag66@shakespeare.lit/pda'
  74. to='darkcave@macbeth.shakespeare.lit'
  75. id='disco2'>
  76. <query xmlns='http://jabber.org/protocol/disco#items'/>
  77. </iq>
  78. ]]></example>
  79. <example caption='Room Returns Items'><![CDATA[
  80. <iq type='result'
  81. from='darkcave@macbeth.shakespeare.lit'
  82. to='hag66@shakespeare.lit/pda'
  83. id='disco2'>
  84. <query xmlns='http://jabber.org/protocol/disco#items'>
  85. ...
  86. <item jid='darkcave@macbeth.shakespeare.lit'
  87. node='files'
  88. name='The files attached to this room'/>
  89. ...
  90. </query>
  91. </iq>
  92. ]]></example>
  93. </section2>
  94. <section2 topic='Offering Entity is not File Owner' anchor='disco-host'>
  95. <p>It is possible that the file owner does not directly support the protocol defined herein and therefore that the offering entity has a JID different from that of the file owner. In this case, the file owner MUST NOT include a feature of "http://jabber.org/protocol/files" in its response to a service discovery information request, as shown in the following example (an end user querying another end user):</p>
  96. <example caption='User Queries Contact Regarding Support'><![CDATA[
  97. <iq type='get'
  98. from='juliet@capulet.com/chamber'
  99. to='romeo@montague.net/home'
  100. id='disco3'>
  101. <query xmlns='http://jabber.org/protocol/disco#info'/>
  102. </iq>
  103. ]]></example>
  104. <example caption='Contact Returns Info'><![CDATA[
  105. <iq type='result'
  106. from='romeo@montague.net/home'
  107. to='juliet@capulet.com/chamber'
  108. id='disco3'>
  109. <query xmlns='http://jabber.org/protocol/disco#info'>
  110. ...
  111. </query>
  112. </iq>
  113. ]]></example>
  114. <p>However, in this case the file owner SHOULD still include the offering entity (e.g., a hosting service) in its response to a service discovery items request:</p>
  115. <example caption='User Queries Contact Regarding Items'><![CDATA[
  116. <iq type='get'
  117. from='juliet@capulet.com/chamber'
  118. to='romeo@montague.net/home'
  119. id='disco4'>
  120. <query xmlns='http://jabber.org/protocol/disco#items'/>
  121. </iq>
  122. ]]></example>
  123. <example caption='Contact Returns Items'><![CDATA[
  124. <iq type='result'
  125. from='romeo@montague.net/home'
  126. to='juliet@capulet.com/chamber'
  127. id='disco4'>
  128. <query xmlns='http://jabber.org/protocol/disco#items'>
  129. ...
  130. <item jid='romeo@files.shakespeare.lit'
  131. node='files'
  132. name='Romeo&apos;s Files'/>
  133. ...
  134. </query>
  135. </iq>
  136. ]]></example>
  137. </section2>
  138. </section1>
  139. <section1 topic='Finding Files' anchor='find'>
  140. <section2 topic='Determining if Files are Available' anchor='find-avail'>
  141. <p>If an offering entity has files to share, it SHOULD reply positively when a requesting entity sends a service discovery items request to the well-known service discovery node "files":</p>
  142. <example caption='Requesting the File List'><![CDATA[
  143. <iq type='get'
  144. from='hag66@shakespeare.lit/pda'
  145. to='darkcave@macbeth.shakespeare.lit'
  146. id='avail'>
  147. <query xmlns='http://jabber.org/protocol/disco#items'
  148. node='files'/>
  149. </iq>
  150. ]]></example>
  151. <p>If the requesting entity is not allowed to view the offering entity's files (the requesting entity is not an occupant of a chatroom, is not registered with the offering entity, is not a contact in a user's roster, etc.) or the offering entity has no files to share, the offering entity SHOULD return an empty &QUERY; element:</p>
  152. <example caption='No Files to Share'><![CDATA[
  153. <iq type='result'
  154. from='darkcave@macbeth.shakespeare.lit'
  155. to='hag66@shakespeare.lit/pda'
  156. id='avail'>
  157. <query xmlns='http://jabber.org/protocol/disco#items'
  158. node='files'/>
  159. </iq>
  160. ]]></example>
  161. <p>If the requesting entity is allowed to view the offering entity's files and the offering entity has files to share, the offering entity SHOULD return a list of items:</p>
  162. <example caption='Returning the File List'><![CDATA[
  163. <iq type='result'
  164. from='darkcave@macbeth.shakespeare.lit'
  165. to='hag66@shakespeare.lit/pda'
  166. id='avail'>
  167. <query xmlns='http://jabber.org/protocol/disco#items'
  168. node='files'>
  169. <item jid='darkcave@macbeth.shakespeare.lit'
  170. node='files/somedir'/>
  171. <item jid='darkcave@macbeth.shakespeare.lit'
  172. node='files/somefile'
  173. name='file1'/>
  174. </query>
  175. </iq>
  176. ]]></example>
  177. <p>Note: The NodeID MUST begin with the string 'files' followed by the '/' character followed the name of the directory or file; further subdirectories or files within a directory MUST follow the same pattern (e.g., "files/somedir/anotherfile"). Thus the protocol defined herein enforces semantic meaning on NodeIDs; this is OPTIONAL within <strong>Service Discovery</strong> but REQUIRED by this document.</p>
  178. <p>If the offering entity has only a few files to share, it may be appropriate to make them available via service discovery only, thus requiring the requesting entity to "walk the tree" of directories and files as described in the <link url="#find-disco">Finding All Files via Service Discovery</link> section. However, if the offering entity has a larger number of files to share, the number of service discovery requests and responses required to "walk the tree" of all directories and files might result in excessive amounts of traffic between the requesting entity and the offering entity; in this case, the offering entity SHOULD provide a "tree file" that defines the hierarchy of directories and files in the standardized format specified in the <link url="#find-tree">Retrieving the Tree File</link> section. The number of files that counts as "large" is not defined herein and is left up to the implementation or deployment; in practice, it is RECOMMENDED for the offering entity to provide a tree file if it has more than five (5) files to share.</p>
  179. </section2>
  180. <section2 topic='Finding All Files via Service Discovery' anchor='find-disco'>
  181. <p>If the offering entity does not provide a tree file, the requesting entity will need to "walk the tree" via service discovery in order to find all the files shared by the offering entity. The previous example showed an offering entity that had two items available: a directory and a file. In order to determine if an item is a directory or a file, the requesting entity MUST send a disco#info request to the relevant node:</p>
  182. <example caption='Requesting Further Information (1)'><![CDATA[
  183. <iq type='get'
  184. from='hag66@shakespeare.lit/pda'
  185. to='darkcave@macbeth.shakespeare.lit'
  186. id='info1'>
  187. <query xmlns='http://jabber.org/protocol/disco#info'
  188. node='files/somedir'/>
  189. </iq>
  190. ]]></example>
  191. <p>If the item is a directory, the offering entity SHOULD return information about the directory, including an identity whose category is "filesys" and whose type is "directory":</p>
  192. <example caption='Returning Further Information (1)'><![CDATA[
  193. <iq type='result'
  194. from='darkcave@macbeth.shakespeare.lit'
  195. to='hag66@shakespeare.lit/pda'
  196. id='info1'>
  197. <query xmlns='http://jabber.org/protocol/disco#info'
  198. node='files/somedir'>
  199. <identity category='filesys' type='directory'/>
  200. </query>
  201. </iq>
  202. ]]></example>
  203. <p>If the requesting entity wants information about every item, it MUST query each item individually:</p>
  204. <example caption='Requesting Further Information (2)'><![CDATA[
  205. <iq type='get'
  206. from='hag66@shakespeare.lit/pda'
  207. to='darkcave@macbeth.shakespeare.lit'
  208. id='info2'>
  209. <query xmlns='http://jabber.org/protocol/disco#info'
  210. node='files/somefile'/>
  211. </iq>
  212. ]]></example>
  213. <p>If the item is a file, the offering entity SHOULD return information about the file, including an identity whose category is "filesys" and whose type is "file":</p>
  214. <example caption='Returning Further Information (2)'><![CDATA[
  215. <iq type='result'
  216. from='darkcave@macbeth.shakespeare.lit'
  217. to='hag66@shakespeare.lit/pda'
  218. id='info2'>
  219. <query xmlns='http://jabber.org/protocol/disco#info'
  220. node='files/somefile'>
  221. <identity category='filesys' type='file' name='file1'/>
  222. </query>
  223. </iq>
  224. ]]></example>
  225. <p>Note: The offering entity MAY also include detailed information about the file, as described in the <link url="#find-details">Determining File Details</link> section of this document.</p>
  226. <p>If the requesting entity wants to find all files, it needs to send a disco#items query to the directory:</p>
  227. <example caption='Requesting Further Items (1)'><![CDATA[
  228. <iq type='get'
  229. from='hag66@shakespeare.lit/pda'
  230. to='darkcave@macbeth.shakespeare.lit'
  231. id='items1'>
  232. <query xmlns='http://jabber.org/protocol/disco#items'
  233. node='files/somedir'/>
  234. </iq>
  235. ]]></example>
  236. <p>The offering entity will then return a list of files and directories contained within the queried directory:</p>
  237. <example caption='Returning Further Items (1)'><![CDATA[
  238. <iq type='result'
  239. from='darkcave@macbeth.shakespeare.lit'
  240. to='hag66@shakespeare.lit/pda'
  241. id='items1'>
  242. <query xmlns='http://jabber.org/protocol/disco#items'
  243. node='files/somedir'>
  244. <item jid='darkcave@macbeth.shakespeare.lit'
  245. node='files/somedir/anotherdir'/>
  246. <item jid='darkcave@macbeth.shakespeare.lit'
  247. node='files/somedir/anotherfile'
  248. name='file2'/>
  249. </query>
  250. </iq>
  251. ]]></example>
  252. <p>The requesting entity then needs to send further disco#info and disco#items requests to the offering entity, specifying the appropriate service discovery nodes...</p>
  253. <example caption='Requesting Further Information (3)'><![CDATA[
  254. <iq type='get'
  255. from='hag66@shakespeare.lit/pda'
  256. to='darkcave@macbeth.shakespeare.lit'
  257. id='info3'>
  258. <query xmlns='http://jabber.org/protocol/disco#info'
  259. node='files/somedir/anotherdir'/>
  260. </iq>
  261. ]]></example>
  262. <example caption='Returning Further Information (3)'><![CDATA[
  263. <iq type='result'
  264. from='darkcave@macbeth.shakespeare.lit'
  265. to='hag66@shakespeare.lit/pda'
  266. id='info3'>
  267. <query xmlns='http://jabber.org/protocol/disco#info'
  268. node='files/somedir/anotherdir'>
  269. <identity category='filesys' type='directory'/>
  270. </query>
  271. </iq>
  272. ]]></example>
  273. <example caption='Requesting Further Information (4)'><![CDATA[
  274. <iq type='get'
  275. from='hag66@shakespeare.lit/pda'
  276. to='darkcave@macbeth.shakespeare.lit'
  277. id='info4'>
  278. <query xmlns='http://jabber.org/protocol/disco#info'
  279. node='files/somedir/anotherfile'/>
  280. </iq>
  281. ]]></example>
  282. <example caption='Returning Further Information (4)'><![CDATA[
  283. <iq type='result'
  284. from='darkcave@macbeth.shakespeare.lit'
  285. to='hag66@shakespeare.lit/pda'
  286. id='info4'>
  287. <query xmlns='http://jabber.org/protocol/disco#info'
  288. node='files/somedir/anotherfile'>
  289. <identity category='filesys' type='file' name='file2'/>
  290. </query>
  291. </iq>
  292. ]]></example>
  293. <example caption='Requesting Further Items (2)'><![CDATA[
  294. <iq type='get'
  295. from='hag66@shakespeare.lit/pda'
  296. to='darkcave@macbeth.shakespeare.lit'
  297. id='items2'>
  298. <query xmlns='http://jabber.org/protocol/disco#items'
  299. node='files/somedir/anotherdir'/>
  300. </iq>
  301. ]]></example>
  302. <example caption='Returning Further Items (2)'><![CDATA[
  303. <iq type='result'
  304. from='darkcave@macbeth.shakespeare.lit'
  305. to='hag66@shakespeare.lit/pda'
  306. id='items2'>
  307. <query xmlns='http://jabber.org/protocol/disco#items'
  308. node='files/somedir/anotherdir'>
  309. <item jid='darkcave@macbeth.shakespeare.lit'
  310. node='files/somedir/anotherdir/yetanotherfile'
  311. name='file3'/>
  312. </query>
  313. </iq>
  314. ]]></example>
  315. <example caption='Requesting Further Information (5)'><![CDATA[
  316. <iq type='get'
  317. from='hag66@shakespeare.lit/pda'
  318. to='darkcave@macbeth.shakespeare.lit'
  319. id='info5'>
  320. <query xmlns='http://jabber.org/protocol/disco#info'
  321. node='files/somedir/anotherdir/yetanotherfile'/>
  322. </iq>
  323. ]]></example>
  324. <example caption='Returning Further Information (5)'><![CDATA[
  325. <iq type='result'
  326. from='darkcave@macbeth.shakespeare.lit'
  327. to='hag66@shakespeare.lit/pda'
  328. id='info5'>
  329. <query xmlns='http://jabber.org/protocol/disco#info'
  330. node='files/somedir/anotherdir/yetanotherfile'>
  331. <identity category='filesys' type='file' name='file3'/>
  332. </query>
  333. </iq>
  334. ]]></example>
  335. <p>In this scenario, we can reconstruct the file tree as follows:</p>
  336. <code><![CDATA[
  337. share
  338. \--somefile
  339. \--somedir
  340. \--anotherfile
  341. \--anotherdir
  342. \--yetanotherfile
  343. ]]></code>
  344. </section2>
  345. <section2 topic='Retrieving the Tree File' anchor='find-tree'>
  346. <p>Obviously, finding all files via service discovery is a tedious process. Therefore, it is RECOMMENDED that the offering entity provide a "tree file" if it has more than five (5) files to share. The format of the tree file is defined by the 'http://jabber.org/profile/si/profile/tree-transfer' namespace that is specified in &xep0105;. The tree file MUST be named "tree.xml" and MUST be available at the well-known service discovery node "tree.xml". The offering entity MAY create a different tree file for each requesting entity (depending on the requesting entity's permissions to view certain directories and files); for this reason, the tree file SHOULD NOT be contained in the root "files" directory itself (note that its NodeID is "tree.xml", not "files/tree.xml").</p>
  347. <p>If the offering entity provides a tree file, it MUST communicate that fact in the disco#items result it returns to the requesting entity in response to the initial request:</p>
  348. <example caption='Requesting the File List'><![CDATA[
  349. <iq type='get'
  350. from='hag66@shakespeare.lit/pda'
  351. to='darkcave@macbeth.shakespeare.lit'
  352. id='avail'>
  353. <query xmlns='http://jabber.org/protocol/disco#items'
  354. node='files'/>
  355. </iq>
  356. ]]></example>
  357. <example caption='Returning the File List'><![CDATA[
  358. <iq type='result'
  359. from='darkcave@macbeth.shakespeare.lit'
  360. to='hag66@shakespeare.lit/pda'
  361. id='avail'>
  362. <query xmlns='http://jabber.org/protocol/disco#items'
  363. node='files'>
  364. <item jid='darkcave@macbeth.shakespeare.lit'
  365. node='files/somedir'/>
  366. <item jid='darkcave@macbeth.shakespeare.lit'
  367. node='files/somefile'
  368. name='file1'/>
  369. <item jid='darkcave@macbeth.shakespeare.lit'
  370. node='tree.xml'
  371. name='Tree File'/>
  372. </query>
  373. </iq>
  374. ]]></example>
  375. <p>If the offering entity includes a service discovery item whose NodeID is "tree.xml", the requesting entity SHOULD retrieve that file (using the protocol specified in the <link url="retrieve">Retrieving a File</link> section) before sending any further service discovery requests to the offering entity.</p>
  376. <p>The following example shows the exact format of the tree file that would represent the file and directory hierarchy discovered via service discovery in the preceding section:</p>
  377. <example caption='A Tree File'><![CDATA[
  378. <tree xmlns='http://jabber.org/profile/si/profile/tree-transfer'
  379. numfiles='3'
  380. size='72521'>
  381. <directory name='files'>
  382. <file sid='file1' name='somefile'/>
  383. <directory name='somedir'>
  384. <file sid='file2' name='anotherfile'/>
  385. <directory name='anotherdir'>
  386. <file sid='file3' name='yetanotherfile'/>
  387. </directory>
  388. </directory>
  389. </directory>
  390. </tree>
  391. ]]></example>
  392. <p>If the offering entity provides a tree file, it is RECOMMENDED (but not required) for the offering entity to also make information about its files discoverable via <strong>Service Discovery</strong> as described in the following section.</p>
  393. </section2>
  394. <section2 topic='Determining File Details' anchor='find-details'>
  395. <p>As is evident from the foregoing examples, neither "walking the tree" via <strong>Service Discovery</strong> nor retrieving the tree file will yield the kind of detailed information about a file (MIME type, file size, descriptive text, etc.) that can help a user or application decide whether to retrieve the file.</p>
  396. <p>To address the felt need for more detailed information about files, an offering entity MAY provide such information in response to disco#info requests sent to a specific NodeID (file or directory) by including extended information structured according to &xep0128;. The following examples illustrate this usage.</p>
  397. <example caption='Requesting File Information'><![CDATA[
  398. <iq type='get'
  399. from='hag66@shakespeare.lit/pda'
  400. to='darkcave@macbeth.shakespeare.lit'
  401. id='file1'>
  402. <query xmlns='http://jabber.org/protocol/disco#info'
  403. node='files/somefile'/>
  404. </iq>
  405. ]]></example>
  406. <example caption='Returning Detailed File Information'><![CDATA[
  407. <iq type='result'
  408. from='darkcave@macbeth.shakespeare.lit'
  409. to='hag66@shakespeare.lit/pda'
  410. id='info2'>
  411. <query xmlns='http://jabber.org/protocol/disco#info'
  412. node='files/somefile'>
  413. <identity category='filesys' type='file' name='file1'/>
  414. <x xmlns='jabber:x:data' type='result'>
  415. <field var='FORM_TYPE' type='hidden'>
  416. <value>http://jabber.org/protocol/files</value>
  417. </field>
  418. <field var='date'>
  419. <value>2004-05-12T02:37:07Z</value>
  420. </field>
  421. <field var='description'>
  422. <value>This is just a test file.</value>
  423. </field>
  424. <field var='hash'>
  425. <value>552da749930852c69ae5d2141d3766b1</value>
  426. </field>
  427. <field var='mime-type'>
  428. <value>text/plain</value>
  429. </field>
  430. <field var='size'>
  431. <value>1022</value>
  432. </field>
  433. </x>
  434. </query>
  435. </iq>
  436. ]]></example>
  437. <p>The fields shown are RECOMMENDED, and are specified more fully in the <link url='#registrar'>XMPP Registrar Considerations</link> section of this document.</p>
  438. </section2>
  439. </section1>
  440. <section1 topic='Retrieving a File' anchor='retrieve'>
  441. <p>In order to retrieve a file, the requesting entity sends a retrieval request to the JID+NodeID of the relevant item:</p>
  442. <example caption='Retrieving a File'><![CDATA[
  443. <iq type='get'
  444. from='hag66@shakespeare.lit/pda'
  445. to='darkcave@macbeth.shakespeare.lit'
  446. id='retrieve1'>
  447. <retrieve xmlns='http://jabber.org/protocol/files'
  448. node='files/somefile'/>
  449. </iq>
  450. ]]></example>
  451. <p>Note: If the requested file was found by means of the tree file rather than service discovery, the NodeID of the retrieve request MUST be constructed according to the rules specified above for service discovery NodeIDs (i.e., 'files' followed by the '/' character followed by the name of the directory or file, followed by additional '/' characters and subdirectory or file names as needed).</p>
  452. <p>If the offering entity agrees to share the file with the requesting entity, it MUST return an IQ result to the requesting entity and then immediately initiate a file transfer to the requesting entity following the protocol defined in &xep0096;:</p>
  453. <example caption='Offering Entity Agrees to Share File'><![CDATA[
  454. <iq type='result' id='retrieve1'/>
  455. ]]></example>
  456. <example caption='Offering Entity Initiates File Transfer'>
  457. <![CDATA[
  458. <iq type='set'
  459. from='darkcave@macbeth.shakespeare.lit'
  460. id='offer1'
  461. to='hag66@shakespeare.lit/pda'>
  462. <si xmlns='http://jabber.org/protocol/si'
  463. id='file1'
  464. mime-type='text/plain'
  465. profile='http://jabber.org/protocol/si/profile/file-transfer'>
  466. <file xmlns='http://jabber.org/protocol/si/profile/file-transfer'
  467. name='somefile'
  468. size='1022'/>
  469. <feature xmlns='http://jabber.org/protocol/feature-neg'>
  470. <x xmlns='jabber:x:data' type='form'>
  471. <field var='stream-method' type='list-single'>
  472. <option><value>http://jabber.org/protocol/bytestreams</value></option>
  473. <option><value>http://jabber.org/protocol/ibb</value></option>
  474. </field>
  475. </x>
  476. </feature>
  477. </si>
  478. </iq>
  479. ]]></example>
  480. <p>The value of the &lt;si/&gt; element's 'id' attribute MUST be the same as the value of the 'sid' attribute communicated in the tree file or the 'name' attribute communicated via service discovery; for this reason, the service discovery 'name' attribute is REQUIRED for NodeIDs that correspond to files, and its value MUST follow the rules for the 'sid' attribute specified in XEP-0105.</p>
  481. <p>Upon receiving the file transfer initiation from the offering entity, the requesting entity SHOULD check the SI 'id' in order to correlate the file transfer with the request; if there is a match, the requesting entity SHOULD silently accept the file transfer and not require intervention by a human before proceeding.</p>
  482. <p>If the offering entity does not agree to share the file with the requesting entity, it MUST return an appropriate IQ error to the requesting entity, such as "Not Authorized", "Forbidden", "Payment Required", "Registration Required", or "Not Found" (see &xep0086; regarding error syntax).</p>
  483. </section1>
  484. <section1 topic='File-Hosting Services' anchor='hosting'>
  485. <p>A dedicated file-hosting service may agree to host files on behalf of a user or other entity, in which case the hosting service (or, to be precise, a specific resource of the hosting service) becomes the offering entity in the use cases defined herein. While the nature of such hosting services is outside the scope of this document, the following guidelines may be helpful to implementers.</p>
  486. <p>First, a file-hosting service SHOULD provide a distinct JID for each account on the service in order to enable communications between the requesting entity and the hosting service. For example, let us suppose that &lt;files.shakespeare.lit&gt; is a file-hosting service; specific accounts on the service could be structured as JIDs of the form &lt;account@files.shakespeare.lit&gt; or &lt;files.shakespeare.lit/account&gt;, in which case the requesting entity would communicate directly with that JID and treat that JID as the offering entity. The file-hosting service SHOULD enable the file owner (e.g., an end user whose JID is &lt;romeo@montague.net&gt;) to upload files to the service using standard Internet protocols (such as HTTP, FTP, scp, or XEP-0096), control who can view or retrieve files, and otherwise configure the offering entity. The file owner SHOULD also list the JID of the "offering entity" in response to service discovery items requests sent to the user's bare JID, so that requesting entities can find files hosted by the service on the file owner's behalf.</p>
  487. <p>It is possible that some Jabber server deployments would choose to offer file-hosting capabilities for their users (if supported in the underlying server implementation), so that the offering entity would have the same &lt;user@host&gt; address as the file owner. In this case, the server itself can be considered a file-hosting service.</p>
  488. </section1>
  489. <section1 topic='Security Considerations' anchor='security'>
  490. <p>Managing access to files and directories is the responsibility of the offering entity. However, the offering entity SHOULD NOT share files with requesting entities that are not known to it via presence subscription, prior registration, room occupancy, or some similar mechanism.</p>
  491. </section1>
  492. <section1 topic='IANA Considerations' anchor='iana'>
  493. <p>No interaction with &IANA; is required as a result of this document.</p>
  494. </section1>
  495. <section1 topic='XMPP Registrar Considerations' anchor='registrar'>
  496. <section2 topic='Protocol Namespaces' anchor='registrar-ns'>
  497. <p>Upon advancement of this document to a status of Draft, the &REGISTRAR; shall add the 'http://jabber.org/protocol/files' namespace to its registry of protocol namespaces.</p>
  498. </section2>
  499. <section2 topic='Well-Known Service Discovery Nodes' anchor='registrar-nodes'>
  500. <p>Upon advancement of this document to a status of Draft, the XMPP Registrar shall add 'files' and 'tree.xml' to its registry of well-known service discovery nodes.</p>
  501. </section2>
  502. <section2 topic='Service Discovery Identities' anchor='registrar-identities'>
  503. <p>Upon advancement of this document to a status of Draft, the XMPP Registrar shall add a category of 'filesys' to its registry of service discovery identities, with two associated types: 'directory' and 'file'.</p>
  504. </section2>
  505. <section2 topic='Field Standardization' anchor='registrar-formtype'>
  506. <p>&xep0068; defines a process for standardizing the fields used within Data Forms scoped by a particular namespace. This document reserves the FORM_TYPE "http://jabber.org/protocol/files" as well as specific fields for use within the context of that FORM_TYPE, as specified in the following registry submission.</p>
  507. <code caption='Registry Submission'><![CDATA[
  508. <form_type>
  509. <name>http://jabber.org/protocol/files</name>
  510. <doc>XEP-01xx</doc>
  511. <desc>Service Discovery extension for file descriptions.</desc>
  512. <field var='date'
  513. type='text-single'
  514. label='Equivalent to date attribute from XEP-0096'/>
  515. <field var='description'
  516. type='text-single'
  517. label='Equivalent to desc element from XEP-0096'/>
  518. <field var='hash'
  519. type='text-single'
  520. label='Equivalent to hash attribute from XEP-0096'/>
  521. <field var='mime-type'
  522. type='text-single'
  523. label='Equivalent to mime-type attribute from XEP-0095'/>
  524. <field var='size'
  525. type='text-single'
  526. label='Equivalent to size attribute from XEP-0096'/>
  527. </form_type>
  528. ]]></code>
  529. </section2>
  530. </section1>
  531. <section1 topic='XML Schema' anchor='schema'>
  532. <code><![CDATA[
  533. <?xml version='1.0' encoding='UTF-8'?>
  534. <xs:schema
  535. xmlns:xs='http://www.w3.org/2001/XMLSchema'
  536. targetNamespace='http://jabber.org/protocol/files'
  537. xmlns='http://jabber.org/protocol/files'
  538. elementFormDefault='qualified'>
  539. <xs:element name='retrieve'>
  540. <xs:complexType>
  541. <xs:simpleContent>
  542. <xs:extension base='empty'>
  543. <xs:attribute name='node' type='xs:string' use='required'/>
  544. </xs:extension>
  545. </xs:simpleContent>
  546. </xs:complexType>
  547. </xs:element>
  548. <xs:simpleType name='empty'>
  549. <xs:restriction base='xs:string'>
  550. <xs:enumeration value=''/>
  551. </xs:restriction>
  552. </xs:simpleType>
  553. </xs:schema>
  554. ]]></code>
  555. </section1>
  556. </xep>