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-0363.xml 16KB

  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>HTTP File Upload</title>
  10. <abstract>This specification defines a protocol to request permissions from another entity to upload a file to a specific path on an HTTP server and at the same time receive a URL from which that file can later be downloaded again.</abstract>
  12. <number>0363</number>
  13. <status>Proposed</status>
  14. <lastcall>2017-12-12</lastcall>
  15. <type>Standards Track</type>
  16. <sig>Standards</sig>
  17. <approver>Council</approver>
  18. <dependencies>
  19. <spec>XMPP Core</spec>
  20. <spec>XEP-0030</spec>
  21. <spec>XEP-0128</spec>
  22. </dependencies>
  23. <supersedes/>
  24. <supersededby/>
  25. <shortname>NOT_YET_ASSIGNED</shortname>
  26. <author>
  27. <firstname>Daniel</firstname>
  28. <surname>Gultsch</surname>
  29. <email></email>
  30. <jid></jid>
  31. </author>
  32. <revision>
  33. <version>0.6.0</version>
  34. <date>2018-04-21</date>
  35. <initials>dg</initials>
  36. <remark>
  37. <ul>
  38. <li>Handling of non ASCII characters in URL</li>
  39. <li>Removed normative language from first paragraph of the security considerations.</li>
  40. </ul>
  41. </remark>
  42. </revision>
  43. <revision>
  44. <version>0.5.0</version>
  45. <date>2018-02-15</date>
  46. <initials>dg</initials>
  47. <remark>
  48. <ul>
  49. <li>Allow only a specific set of HTTP headers to be included in the request</li>
  50. <li>Removed some inappropriate use of normative language</li>
  51. </ul>
  52. </remark>
  53. </revision>
  54. <revision>
  55. <version>0.4.0</version>
  56. <date>2017-12-03</date>
  57. <initials>dg</initials>
  58. <remark>
  59. <ul>
  60. <li>Added &lt;retry/&gt; element to error response</li>
  61. <li>Extend Security Considerations</li>
  62. </ul>
  63. </remark>
  64. </revision>
  65. <revision>
  66. <version>0.3.1</version>
  67. <date>2017-04-21</date>
  68. <initials>dg</initials>
  69. <remark><p>Fixed example</p></remark>
  70. </revision>
  71. <revision>
  72. <version>0.3.0</version>
  73. <date>2017-02-01</date>
  74. <initials>dg</initials>
  75. <remark><p>Slight syntax changes and added ability to provide additional HTTP header fields on slot assignment.</p></remark>
  76. </revision>
  77. <revision>
  78. <version>0.2.5</version>
  79. <date>2017-01-08</date>
  80. <initials>XEP Editor: ssw</initials>
  81. <remark><p>Merge typo fixes suggested by an unnamed user.</p></remark>
  82. </revision>
  83. <revision>
  84. <version>0.2.4</version>
  85. <date>2016-10-28</date>
  86. <initials>dg (XEP Editor: ssw)</initials>
  87. <remark><p>Fix TLS reference</p></remark>
  88. </revision>
  89. <revision>
  90. <version>0.2.3</version>
  91. <date>2016-07-11</date>
  92. <initials>wjt (XEP Editor: ssw)</initials>
  93. <remark><p>Typo fixes</p></remark>
  94. </revision>
  95. <revision>
  96. <version>0.2.2</version>
  97. <date>2016-03-30</date>
  98. <initials>ssw</initials>
  99. <remark><p>Typo fix</p></remark>
  100. </revision>
  101. <revision>
  102. <version>0.2.1</version>
  103. <date>2016-03-16</date>
  104. <initials>XEP Editor (ssw)</initials>
  105. <remark><p>Minor dependency and citation fixes (fs).</p></remark>
  106. </revision>
  107. <revision>
  108. <version>0.2</version>
  109. <date>2016-03-07</date>
  110. <initials>dg</initials>
  111. <remark><p>Announce maximum file size by means of &xep0128;</p></remark>
  112. </revision>
  113. <revision>
  114. <version>0.1.2</version>
  115. <date>2016-02-16</date>
  116. <initials>XEP Editor (mam)</initials>
  117. <remark><p>Fix typo of discovery (Philipp Hancke).</p></remark>
  118. </revision>
  119. <revision>
  120. <version>0.1.1</version>
  121. <date>2016-01-05</date>
  122. <initials>XEP Editor (ssw)</initials>
  123. <remark><p>Fix invalid XML in examples (tpa).</p></remark>
  124. </revision>
  125. <revision>
  126. <version>0.1</version>
  127. <date>2015-08-27</date>
  128. <initials>XEP Editor (mam)</initials>
  129. <remark><p>Initial published version approved by the XMPP Council.</p></remark>
  130. </revision>
  131. <revision>
  132. <version>0.0.1</version>
  133. <date>2015-07-25</date>
  134. <initials>dg</initials>
  135. <remark><p>First draft.</p></remark>
  136. </revision>
  137. </header>
  138. <section1 topic='Introduction' anchor='intro'>
  139. <p>XMPP protocol extensions already define methods for peer-to-peer file transfer such as &xep0096; or &xep0234; however due to their very nature of being peer-to-peer they don't work very well in scenarios where it is requeried to send a file to multiple recipients or multiple resources of the same recipient at once. They also don’t work alongside offline storage, MUC history and &xep0313;.</p>
  140. <p>Uploading files manually to an HTTP server and sharing the link has been a workaround for this for a long time now. While users have a variety of services to choose from the downside of this manual approach is that an XMPP client can not automate this process on behalf of the user since these services don’t share a common API. Furthermore using a third party service would probably require the user to enter additional credentials into their XMPP client specifically for the file upload.</p>
  141. <p>This XEP defines an approach to request permissions from another entity to upload a file to a specific path on an HTTP server and at the same time receive an URL from which that file can later be downloaded again. These tuples consisting of a PUT and a GET-URL are called slots.</p>
  142. </section1>
  143. <section1 topic='Requirements' anchor='reqs'>
  144. <ul>
  145. <li>Be as easy to implement as possible. This is grounded on the idea that most programming languages already have HTTP libraries available.</li>
  146. <li>Be agnostic toward the distribution of the actual URL. Users can choose to send the URL in the body of a message stanza, utilize &xep0066;, &xep0370;, or even use it as their avatar in &xep0084;</li>
  147. <li>Do not provide any kind of access control or security for file retrieval beyond Transport Layer Security in form of HTTPS and long random paths that are impossible to guess. That means everyone who knows the URL SHOULD be able to access it.</li>
  148. </ul>
  149. </section1>
  150. <section1 topic='Discovering Support' anchor='disco'>
  151. <p>An entity advertises support for this protocol by including the "urn:xmpp:http:upload:0" in its service discovery information features as specified in &xep0030; or section 6.3 of &xep0115;. To avoid unnecessary round trips an entity SHOULD also include the maximum file size as specified in &xep0128; if such a limitation exists. The field name MUST be "max-file-size" and the value MUST be in bytes.</p>
  152. <p>A user’s server SHOULD include any known entities that provide such services into its service discovery items.</p>
  153. <example caption='Client sends service discovery request to server'><![CDATA[
  154. <iq from='romeo@montague.tld/garden'
  155. id='step_01'
  156. to='montague.tld'
  157. type='get'>
  158. <query xmlns=''/>
  159. </iq>]]></example>
  160. <example caption='Server replies to service discovery request'><![CDATA[
  161. <iq from='montague.tld'
  162. id='step_01'
  163. to='romeo@montague.tld/garden'
  164. type='result'>
  165. <query xmlns=''>
  166. <item jid='upload.montague.tld' name='HTTP File Upload' />
  167. <item jid='conference.montague.tld' name='Chatroom Service' />
  168. </query>
  169. </iq>]]></example>
  170. <example caption='Client sends service discovery request to upload service'><![CDATA[
  171. <iq from='romeo@montague.tld/garden'
  172. id='step_02'
  173. to='upload.montague.tld'
  174. type='get'>
  175. <query xmlns=''/>
  176. </iq>]]></example>
  177. <example caption='Upload service replies to service discovery request and reports a maximum file size of 5MiB'><![CDATA[
  178. <iq from='upload.montague.tld'
  179. id='step_02'
  180. to='romeo@montague.tld/garden'
  181. type='result'>
  182. <query xmlns=''>
  183. <identity category='store'
  184. type='file'
  185. name='HTTP File Upload' />
  186. <feature var='urn:xmpp:http:upload:0' />
  187. <x type='result' xmlns='jabber:x:data'>
  188. <field var='FORM_TYPE' type='hidden'>
  189. <value>urn:xmpp:http:upload:0</value>
  190. </field>
  191. <field var='max-file-size'>
  192. <value>5242880</value>
  193. </field>
  194. </x>
  195. </query>
  196. </iq>]]></example>
  197. </section1>
  198. <section1 topic='Requesting a slot' anchor='request'>
  199. <p>A client requests a new upload slot by sending an IQ-get to the upload service containing a &lt;request&gt; child element qualified by the urn:xmpp:http:upload:0 namespace. This element MUST include the attributes filename and size containing the file name and size respectively.</p>
  200. <p>An additional attribute content-type containing the Content-Type is OPTIONAL.</p>
  201. <example caption='Client requests a slot on the upload service'><![CDATA[
  202. <iq from='romeo@montague.tld/garden'
  203. id='step_03'
  204. to='upload.montague.tld'
  205. type='get'>
  206. <request xmlns='urn:xmpp:http:upload:0'
  207. filename='très cool.jpg'
  208. size='23456'
  209. content-type='image/jpeg' />
  210. </iq>]]></example>
  211. <p>The upload service responds with both a PUT and a GET URL wrapped by a &lt;slot&gt; element. The service SHOULD keep the file name and especially the file ending intact. Using the same hostname for PUT and GET is OPTIONAL. The host MUST provide Transport Layer Security (&rfc5246;). Both HTTPS URLs MUST adhere to &rfc3986;. Non ASCII characters MUST be percent-encoded.</p>
  212. <p>The &lt;put&gt; element MAY also contain a number of &lt;header&gt; elements which correspond to HTTP header fields. Each &lt;header&gt; element MUST have a name-attribute and a content with the value of the header. Only the following header names are allowed: Authorization, Cookie, Expires. Other header names MUST be ignored by the requesting entity and MUST NOT be included in the HTTP request. The requesting entity MUST strip any newline characters from the header name and value before performing the HTTP request.</p>
  213. <example caption='The upload service responds with a slot'><![CDATA[
  214. <iq from='upload.montague.tld'
  215. id='step_03'
  216. to='romeo@montague.tld/garden'
  217. type='result'>
  218. <slot xmlns='urn:xmpp:http:upload:0'>
  219. <put url='https://upload.montague.tld/4a771ac1-f0b2-4a4a-9700-f2a26fa2bb67/tr%C3%A8s%20cool.jpg'>
  220. <header name='Authorization'>Basic Base64String==</header>
  221. <header name='Cookie'>foo=bar; user=romeo</header>
  222. </put>
  223. <get url='https://download.montague.tld/4a771ac1-f0b2-4a4a-9700-f2a26fa2bb67/tr%C3%A8s%20cool.jpg' />
  224. </slot>
  225. </iq>]]></example>
  226. </section1>
  227. <section1 topic='Error conditions' anchor='errors'>
  228. <p>Instead of providing the client with a slot the service MAY respond with an error if the requested file size is too large.</p>
  229. <example caption='Alternative response by the upload service if the file size was too large'><![CDATA[
  230. <iq from='upload.montague.tld'
  231. id='step_03'
  232. to='romeo@montague.tld/garden'
  233. type='error'>
  234. <request xmlns='urn:xmpp:http:upload:0'
  235. filename='très cool.jpg'
  236. size='23456'
  237. content-type='image/jpeg' />
  238. <error type='modify'>
  239. <not-acceptable xmlns='urn:ietf:params:xml:ns:xmpp-stanzas' />
  240. <text xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'>File too large. The maximum file size is 20000 bytes</text>
  241. <file-too-large xmlns='urn:xmpp:http:upload:0'>
  242. <max-file-size>20000</max-file-size>
  243. </file-too-large>
  244. </error>
  245. </iq>]]></example>
  246. <p>For any other type of error the service SHOULD respond with appropriate error types to indicate temporary or permanent errors.</p>
  247. <p>For temporary errors such as exceeding a personal quota the service MAY include a &lt;retry/&gt; element qualified by the urn:xmpp:http:upload:0 namespace as a child of the &lt;error/&gt; element. The retry element MUST include an attribute 'stamp' which indicates the time at which the requesting entity may try again. The format of the timestamp MUST adhere to the date-time format specified in &xep0082; and MUST be expressed in UTC.</p>
  248. <example caption='Alternative response by the upload service to indicate a temporary error after the client exceeded a quota'><![CDATA[
  249. <iq from='upload.montague.tld'
  250. id='step_03'
  251. to='romeo@montague.tld/garden'
  252. type='error'>
  253. <request xmlns='urn:xmpp:http:upload:0'
  254. filename='très cool.jpg'
  255. size='23456'
  256. content-type='image/jpeg' />
  257. <error type='wait'>
  258. <resource-constraint xmlns='urn:ietf:params:xml:ns:xmpp-stanzas' />
  259. <text xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'>Quota reached. You can only upload 5 files in 5 minutes</text>
  260. <retry xmlns='urn:xmpp:http:upload:0'
  261. stamp='2017-12-03T23:42:05Z' />
  262. </error>
  263. </iq>]]></example>
  264. <example caption='Alternative response by the upload service to indicate a permanent error to a client that is not allowed to upload files'><![CDATA[
  265. <iq from='upload.montague.tld'
  266. id='step_03'
  267. to='romeo@montague.tld/garden'
  268. type='error'>
  269. <request xmlns='urn:xmpp:http:upload:0'
  270. filename='très cool.jpg'
  271. size='23456'
  272. content-type='image/jpeg' />
  273. <error type='cancel'>
  274. <not-allowed xmlns='urn:ietf:params:xml:ns:xmpp-stanzas' />
  275. <text xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'>Only premium members are allowed to upload files</text>
  276. </error>
  277. </iq>]]></example>
  278. </section1>
  279. <section1 topic='Upload' anchor='upload'>
  280. <p>The actual upload of the file happens via HTTP-PUT and is out of scope of this document. The upload service MUST reject the file upload if the Content-Length does not match the size of the slot request. The service SHOULD reject the file if the Content-Type has been specified beforehand and does not match. The service MAY assume application/octet-stream as a Content-Type if it the client did not specify a Content-Type at all.</p>
  281. <p>In addition to the Content-Length and Content-Type header the client MUST include all allowed headers that came with the slot assignment.</p>
  282. <p>There is no further XMPP communication required between the upload service and the client. A HTTP status Code of 201 means that the server is now ready to serve the file via the provided GET URL. If the upload fails for whatever reasons the client MAY request a new slot.</p>
  283. </section1>
  284. <section1 topic='Implementation Notes' anchor='impl'>
  285. <p>The upload service SHOULD choose an appropriate timeout for the validity of the PUT URL. Since there is no reason for a client to wait between requesting the slot and starting the upload, relatively low timeout values of around 60s are RECOMMENDED.</p>
  286. </section1>
  287. <section1 topic='Security Considerations' anchor='security'>
  288. <ul>
  289. <li>Implementors should keep in mind, that without additional end-to-end-encryption, files uploaded to a service described in this document may be stored in plain text. Client implementors are advised to either use this only for semi public files (for example files shared in a public MUC or a PEP Avatar) or implement appropriate end-to-end encryption.</li>
  290. <li>Requesting entities MUST strip any newline characters from the HTTP header names and values before making the PUT request.</li>
  291. <li>Requesting entities MUST ensure that only the headers that are explicitly allowed by this XEP (Authorization, Cookie, Expires) are copied from the slot response to the HTTP request.</li>
  292. <li>Service implementors SHOULD use long randomized parts in their URLs making it impossible to guess the location of arbitrary files</li>
  293. </ul>
  294. </section1>
  295. <section1 topic='IANA Considerations' anchor='iana'>
  296. <p>This document requires no interaction with the Internet Assigned Numbers Authority (IANA).</p>
  297. </section1>
  298. <section1 topic='XMPP Registrar Considerations' anchor='registrar'>
  299. <section2 topic='Protocol Namespaces' anchor='registrar-ns'>
  300. <p>This specification defines the following XML namespace:</p>
  301. <ul>
  302. <li>urn:xmpp:http:upload:0</li>
  303. </ul>
  304. <p>Upon advancement of this specification from a status of Experimental to a status of Draft, the &REGISTRAR; shall add the foregoing namespace to the registry located at &NAMESPACES;, as described in Section 4 of &xep0053;.</p>
  305. </section2>
  306. </section1>
  307. <section1 topic='XML Schema' anchor='schema'>
  308. <p>tbd</p>
  309. </section1>
  310. </xep>