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.
 
 
 
 
 
 

443 lines
17 KiB

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE xep SYSTEM 'xep.dtd' [
<!ENTITY % ents SYSTEM 'xep.ent'>
%ents;
]>
<?xml-stylesheet type='text/xsl' href='xep.xsl'?>
<xep>
<header>
<title>SI File Transfer</title>
<abstract>This specification defines a profile of the XMPP stream initiation extension for transferring files between two entities. The protocol provides a modular framework that enables the exchange of information about the file to be transferred as well as the negotiation of parameters such as the transport to be used.</abstract>
&LEGALNOTICE;
<number>0096</number>
<status>Draft</status>
<type>Standards Track</type>
<sig>Standards</sig>
<dependencies>
<spec>XMPP Core</spec>
<spec>XEP-0095</spec>
</dependencies>
<supersedes/>
<supersededby/>
<shortname>si-filetransfer</shortname>
<schemaloc>
<url>http://www.xmpp.org/schemas/file-transfer.xsd</url>
</schemaloc>
&temas;
&linuxwolf;
&reatmon;
&stpeter;
<revision>
<version>1.2</version>
<date>2004-04-13</date>
<initials>psa</initials>
<remark>More fully defined the XMPP Registrar considerations.</remark>
</revision>
<revision>
<version>1.1</version>
<date>2003-12-30</date>
<initials>psa</initials>
<remark>Improved explanatory text; fixed several errors in the schema.</remark>
</revision>
<revision>
<version>1.0</version>
<date>2003-10-17</date>
<initials>psa</initials>
<remark>Per a vote of the Jabber Council, advanced status to Draft.</remark>
</revision>
<revision>
<version>0.7</version>
<date>2003-10-07</date>
<initials>tjm</initials>
<remark>Added IBB as a MUST requirement.</remark>
</revision>
<revision>
<version>0.6</version>
<date>2003-08-18</date>
<initials>tjm</initials>
<remark>Cleaned up some namespace inconsistencies, added the &lt;desc&gt;
element for file descriptions.</remark>
</revision>
<revision>
<version>0.5</version>
<date>2003-07-15</date>
<initials>rwe</initials>
<remark>Stream ids not needed on return results. Moved s5b, ibb, and url-data to the actual namespaces of the stream protocols.</remark>
</revision>
<revision>
<version>0.4</version>
<date>2003-06-30</date>
<initials>lw</initials>
<remark>Fixed various typos and inconsistencies</remark>
</revision>
<revision>
<version>0.3</version>
<date>2003-06-30</date>
<initials>lw</initials>
<remark>Added XML Schema</remark>
</revision>
<revision>
<version>0.2</version>
<date>2003-06-24</date>
<initials>tjm</initials>
<remark>
Clarified many examples, added linuxwolf as an author (again, my bad,
should have been there), clarified the allowed streams and how data is
sent over it.
</remark>
</revision>
<revision>
<version>0.1</version>
<date>2003-06-10</date>
<initials>tjm</initials>
<remark>Initial version.</remark>
</revision>
</header>
<section1 topic='Introduction' anchor='intro'>
<p>The traditional mechanism for transferring files in the Jabber community is the &xep0066; protocol. That protocol has several drawbacks:</p>
<ol>
<li>It is not reliable.</li>
<li>It does not work when one of the parties is behind a firewall.</li>
<li>It provides limited metadata about files to be exchanged.</li>
</ol>
<p>The current document defines a profile of &xep0095; that solves the problems with out-of-band data, thus providing a robust, reliable mechanism for file transfers over the Jabber network. Implementors are referred to XEP-0095 regarding the underlying concepts of stream initiation.</p>
</section1>
<section1 topic='Requirements' anchor='reqs'>
<ul>
<li>Enable seamless file transfer, including fall-back mechanisms as appropriate.</li>
<li>Ensure that the profile will work even when one or both parties are behind a firewall.</li>
<li><p>Define a full-featured set of metadata for file transfers, including the following:</p>
<ul>
<li>description</li>
<li>size</li>
<li>name</li>
<li>date</li>
<li>hash</li>
</ul>
</li>
<li>Optionally support ranged transfers.</li>
</ul>
</section1>
<section1 topic='Protocol' anchor='protocol'>
<p>
The file transfer profile is in the
"http://jabber.org/protocol/si/profile/file-transfer" namespace.
The profile is fairly simple: it consists of the root element
with the possibility of one child describing the optional ranged transfers.
</p>
<p>
The root element is &lt;file&gt; and has four attributes. The attributes
are used only during the offer stage of stream initiation:</p>
<ul>
<li><em>size</em> - The size, in bytes, of the data to be sent.</li>
<li><em>name</em> - The name of the file that the Sender wishes to send.</li>
<li><em>date</em> - The last modification time of the file. This is
specified using the DateTime profile as described in &xep0082;.</li>
<li><em>hash</em> - The MD5 sum of the file contents.</li>
</ul>
<p>The <em>size</em> and <em>name</em> attributes MUST be present in the
profile. The other attributes MAY be present.
</p>
<p>
There are two possible child elements of the root: &lt;desc&gt; and
&lt;range&gt;. Both are OPTIONAL.
</p>
<p>
&lt;desc&gt; is used to provide a sender-generated description of the file so
the receiver can better understand what is being sent. It MUST NOT be sent in
the result.
</p>
<p>
When &lt;range&gt; is sent in the offer, it should have no
attributes. This signifies that the
sender can do ranged transfers. When a Stream Initiation result is sent
with the &lt;range&gt; element, it uses these attributes:</p>
<ul>
<li>
<em>offset</em> - Specifies the position, in bytes, to start
transferring the file data from. This defaults to zero (0) if not
specified.
</li>
<li>
<em>length</em> - Specifies the number of bytes to retrieve starting
at offset. This defaults to the length of the file from offset to the
end.
</li>
</ul>
<p>Both attributes are OPTIONAL on the &lt;range&gt; element. Sending no
attributes is synonymous with not sending the &lt;range&gt;
element. When no &lt;range&gt; element is sent in the
Stream Initiation result, the Sender MUST send the complete file starting at
offset 0. More generally, data is sent over the stream byte for byte starting
at the offset position for the length specified.
</p>
<section2 topic='Mandatory-to-Implement Technologies' anchor='protocol-tech'>
<p>In order to enable seamless file transfer and appropriate fall-back mechanisms, implementations of this profile MUST support both &xep0065; and &xep0047;, to be preferred in that order. The associated namespaces are to be included as option values for the "stream-method" variable as shown in the examples below.</p>
<p>Additionally, implementations MAY support other mechanisms.</p>
</section2>
</section1>
<section1 topic='Examples' anchor='examples'>
<example caption='Simple Profile Usage in Stream Initiation Offer'>
<![CDATA[
<iq type='set' id='offer1' to='receiver@jabber.org/resource'>
<si xmlns='http://jabber.org/protocol/si'
id='a0'
mime-type='text/plain'
profile='http://jabber.org/protocol/si/profile/file-transfer'>
<file xmlns='http://jabber.org/protocol/si/profile/file-transfer'
name='test.txt'
size='1022'/>
<feature xmlns='http://jabber.org/protocol/feature-neg'>
<x xmlns='jabber:x:data' type='form'>
<field var='stream-method' type='list-single'>
<option><value>http://jabber.org/protocol/bytestreams</value></option>
<option><value>http://jabber.org/protocol/ibb</value></option>
</field>
</x>
</feature>
</si>
</iq>
]]>
</example>
<example caption='Simple Profile Usage in Stream Initiation Result'>
<![CDATA[
<iq type='result' to='sender@jabber.org/resource' id='offer1'>
<si xmlns='http://jabber.org/protocol/si'>
<feature xmlns='http://jabber.org/protocol/feature-neg'>
<x xmlns='jabber:x:data' type='submit'>
<field var='stream-method'>
<value>http://jabber.org/protocol/bytestreams</value>
</field>
</x>
</feature>
</si>
</iq>
]]>
</example>
<example caption='Complete Profile Usage in Stream Initiation Offer'>
<![CDATA[
<iq type='set' id='offer1' to='receiver@jabber.org/resource'>
<si xmlns='http://jabber.org/protocol/si'
id='a0'
mime-type='text/plain'
profile='http://jabber.org/protocol/si/profile/file-transfer'>
<file xmlns='http://jabber.org/protocol/si/profile/file-transfer'
name='test.txt'
size='1022'
hash='552da749930852c69ae5d2141d3766b1'
date='1969-07-21T02:56:15Z'>
<desc>This is a test. If this were a real file...</desc>
</file>
<feature xmlns='http://jabber.org/protocol/feature-neg'>
<x xmlns='jabber:x:data' type='form'>
<field var='stream-method' type='list-single'>
<option><value>http://jabber.org/protocol/bytestreams</value></option>
<option><value>http://jabber.org/protocol/ibb</value></option>
</field>
</x>
</feature>
</si>
</iq>
]]>
</example>
<example caption='Complete Profile Usage in Stream Initiation Result'>
<![CDATA[
<iq type='result' to='sender@jabber.org/resource' id='offer1'>
<si xmlns='http://jabber.org/protocol/si'>
<file xmlns='http://jabber.org/protocol/si/profile/file-transfer'/>
<feature xmlns='http://jabber.org/protocol/feature-neg'>
<x xmlns='jabber:x:data' type='submit'>
<field var='stream-method'>
<value>http://jabber.org/protocol/bytestreams</value>
</field>
</x>
</feature>
</si>
</iq>
]]>
</example>
<p>This range should retrieve 256 bytes from the beginning of the file:</p>
<example>
<![CDATA[
<range length='256'/>
]]>
</example>
<p>This range should retrieve 256 bytes starting from the 128th byte in the file:</p>
<example>
<![CDATA[
<range offset='128' length='256'/>
]]>
</example>
<p>This range should retrieve the remainder of the file starting at the 128th byte in the file:</p>
<example>
<![CDATA[
<range offset='128'/>
]]>
</example>
<p>This range is the same as having not sent the range request and the entire file is sent:</p>
<example>
<![CDATA[
<range/>
]]>
</example>
</section1>
<section1 topic='IANA Considerations' anchor='iana'>
<p>No interaction with &IANA; is required as a result of this document.</p>
</section1>
<section1 topic='XMPP Registrar Considerations' anchor='registrar'>
<section2 topic='Stream Initiation Profiles' anchor='registrar-siprofiles'>
<p>The profile described in this document is included in the stream initiation profiles registry maintained by the &REGISTRAR; (see &SIPROFILES;). The registry submission is as follows:</p>
<code><![CDATA[
<profile>
<name>http://jabber.org/protocol/si/profile/file-transfer</name>
<doc>XEP-0096</doc>
<desc>A profile for file transfer between any two entities.</desc>
</profile>
]]></code>
</section2>
<section2 topic='URI Query Types' anchor='registrar-querytypes'>
<p>As authorized by &xep0147;, the XMPP Registrar maintains a registry of queries and key-value pairs for use in XMPP URIs (see &QUERYTYPES;).</p>
<p>As described below, the registered querytypes for file transfer actions are "sendfile" and "recvfile". Note well that "sendfile" means a second entity will send a file to the XMPP entity that controls the IRI/URI and that "recvfile" means a second entity will receive a file from the XMPP entity that controls the IRI/URI.</p>
<section3 topic='sendfile' anchor='registrar-querytypes-sendfile'>
<p>To enable a second entity to send a file, the IRI/URI is of the following form:</p>
<example caption='Sending a File: IRI/URI'><![CDATA[
xmpp:romeo@montague.net/orchard?sendfile
]]></example>
<p>The application SHOULD then present an interface enabling the user to provide information about the file to be sent (e.g., by "browsing" the file system of the user's computer in order to choose a file). As a result, the application SHOULD then send a &xep0137; message to the XMPP address encapsulated in the IRI/URI:</p>
<example caption='Sending a File: Resulting Stanza'><![CDATA[
<message from='juliet@capulet.com/balcony' to='romeo@montague.net'>
<sipub xmlns='http://jabber.org/protocol/si-pub'
id='publish-0123'
mime-type='text/plain'
profile='http://jabber.org/protocol/si/profile/file-transfer'>
<file xmlns='http://jabber.org/protocol/si/profile/file-transfer'
name='missive.txt'
size='1024'
date='2005-11-29T11:21Z'/>
</sipub>
</message>
]]></example>
<p>The following submission registers the "sendfile" querytype.</p>
<code><![CDATA[
<querytype>
<name>sendfile</name>
<proto>http://jabber.org/protocol/si/profile/file-transfer</proto>
<desc>enables initiation of an inbound file transfer to XMPP entity</desc>
<doc>XEP-0096</doc>
</querytype>
]]></code>
</section3>
<section3 topic='recvfile' anchor='registrar-querytypes-recvfile'>
<p>To enable a second entity to receive a file, the IRI/URI is of the following form:</p>
<example caption='Receiving a File: IRI/URI'><![CDATA[
xmpp:romeo@montague.net/orchard?recvfile;sid=pub234;mime-type=text%2Fplain;name=reply.txt;size=2048
]]></example>
<p>That IRI/URI is equivalent to the following XML stanza:</p>
<example caption='Receiving a File: Equivalent Stanza'><![CDATA[
<message from='romeo@montague.net' to='juliet@capulet.com/balcony'>
<sipub xmlns='http://jabber.org/protocol/si-pub'
id='pub234'
mime-type='text/plain'
profile='http://jabber.org/protocol/si/profile/file-transfer'>
<file xmlns='http://jabber.org/protocol/si/profile/file-transfer'
name='reply.txt'
size='2048'/>
</sipub>
</message>
]]></example>
<p>In accordance with <cite>XEP-0137</cite>, the application SHOULD then initiate a file transfer exchange with by sending a stanza of the following form:</p>
<example caption='Receiving a File: Resulting Stanza'><![CDATA[
<iq from='juliet@capulet.com/balcony' to='romeo@montague.net/orchard'>
<start xmlns='http://jabber.org/protocol/si-pub' id='pub234'/>
</iq>
]]></example>
<p>Note well that the request to begin the stream is sent to the full JID (user@host/resource) of the XMPP entity identified by the XMPP IRI/URI. Therefore, the IRI/URI SHOULD include a full JID. If it does not, the receiver MUST discover a full JID via presence or service discovery. If the receiver cannot discover a full JID for the sender (e.g., in the last resort through sending a presence subscription request to the sender and receiving presence from the sender's resources), then it SHOULD abort the file transfer exchange.</p>
<p>The following submission registers the "recvfile" querytype.</p>
<code><![CDATA[
<querytype>
<name>recvfile</name>
<proto>http://jabber.org/protocol/si/profile/file-transfer</proto>
<desc>enables initiation of an outbound file transfer from XMPP entity</desc>
<doc>XEP-0096</doc>
<keys>
<key>
<name>algo</name>
<desc>the hash algorithm used to generate the checksum</desc>
</key>
<key>
<name>hash</name>
<desc>a checksum of the file contents</desc>
</key>
<key>
<name>mime-type</name>
<desc>the MIME type of the file being offered</desc>
</key>
<key>
<name>name</name>
<desc>the name of the file being offered</desc>
</key>
<key>
<name>sid</name>
<desc>the session ID associated with the file being offered</desc>
</key>
<key>
<name>size</name>
<desc>the size in bytes of the file being offered</desc>
</key>
</keys>
</querytype>
]]></code>
</section3>
</section2>
</section1>
<section1 topic='XML Schema' anchor='schema'>
<code><![CDATA[
<?xml version='1.0' encoding='UTF-8'?>
<xs:schema
xmlns:xs='http://www.w3.org/2001/XMLSchema'
targetNamespace='http://jabber.org/protocol/si/profile/file-transfer'
xmlns='http://jabber.org/protocol/si/profile/file-transfer'
elementFormDefault='qualified'>
<xs:annotation>
<xs:documentation>
The protocol documented by this schema is defined in
XEP-0096: http://www.xmpp.org/extensions/xep-0096.html
</xs:documentation>
</xs:annotation>
<xs:element name='file'>
<xs:complexType>
<xs:sequence minOccurs='0'>
<xs:element name='desc' type='xs:string'/>
<xs:element ref='range'/>
</xs:sequence>
<xs:attribute name='date' type='xs:string' use='optional'/>
<xs:attribute name='hash' type='xs:string' use='optional'/>
<xs:attribute name='name' type='xs:string' use='required'/>
<xs:attribute name='size' type='xs:integer' use='required'/>
</xs:complexType>
</xs:element>
<xs:element name='range'>
<xs:complexType>
<xs:simpleContent>
<xs:extension base='empty'>
<xs:attribute name='length' type='xs:integer' use='optional'/>
<xs:attribute name='offset' type='xs:integer' use='optional'/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:simpleType name='empty'>
<xs:restriction base='xs:string'>
<xs:enumeration value=''/>
</xs:restriction>
</xs:simpleType>
</xs:schema>
]]></code>
</section1>
</xep>