<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type='text/xsl' href='xep.xsl'?>
<xep xmlns="">
<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>
  
<legal>
<copyright>This XMPP Extension Protocol is copyright © 1999 – 2024 by the <link url="https://xmpp.org/">XMPP Standards Foundation</link> (XSF).</copyright>
<permissions>Permission is hereby granted, free of charge, to any person obtaining a copy of this specification (the "Specification"), to make use of the Specification without restriction, including without limitation the rights to implement the Specification in a software program, deploy the Specification in a network service, and copy, modify, merge, publish, translate, distribute, sublicense, or sell copies of the Specification, and to permit persons to whom the Specification is furnished to do so, subject to the condition that the foregoing copyright notice and this permission notice shall be included in all copies or substantial portions of the Specification. Unless separate permission is granted, modified works that are redistributed shall not contain misleading information regarding the authors, title, number, or publisher of the Specification, and shall not claim endorsement of the modified works by the authors, any organization or project to which the authors belong, or the XMPP Standards Foundation.</permissions>
<warranty>## NOTE WELL: This Specification is provided on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. ##</warranty>
<liability>In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall the XMPP Standards Foundation or any author of this Specification be liable for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising from, out of, or in connection with the Specification or the implementation, deployment, or other use of the Specification (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if the XMPP Standards Foundation or such author has been advised of the possibility of such damages.</liability>
<conformance>This XMPP Extension Protocol has been contributed in full conformance with the XSF's Intellectual Property Rights Policy (a copy of which can be found at &lt;<link url="https://xmpp.org/about/xsf/ipr-policy">https://xmpp.org/about/xsf/ipr-policy</link>&gt; or obtained by writing to XMPP Standards Foundation, P.O. Box 787, Parker, CO 80134 USA).</conformance>
</legal>
  <number>0096</number>
  <status>Deprecated</status>
  <type>Standards Track</type>
  <sig>Standards</sig>
  <approver>Council</approver>
  <dependencies>
    <spec>XMPP Core</spec>
    <spec>XEP-0095</spec>
  </dependencies>
  <supersedes/>
  <supersededby><spec>XEP-0234</spec></supersededby>
  <shortname>si-filetransfer</shortname>
  <schemaloc>
    <url>http://www.xmpp.org/schemas/file-transfer.xsd</url>
  </schemaloc>
  
  <author>
    <firstname>Thomas</firstname>
    <surname>Muldowney</surname>
    <email>temas@jabber.org</email>
    <jid>temas@jabber.org</jid>
  </author>

  
  <author>
    <firstname>Matthew</firstname>
    <surname>Miller</surname>
    <email>linuxwolf@outer-planes.net</email>
    <jid>linuxwolf@outer-planes.net</jid>
  </author>

  
  <author>
    <firstname>Ryan</firstname>
    <surname>Eatmon</surname>
    <email>reatmon@jabber.org</email>
    <jid>reatmon@jabber.org</jid>
  </author>

  
  <author>
    <firstname>Peter</firstname>
    <surname>Saint-Andre</surname>
    <email>stpeter@stpeter.im</email>
    <jid>stpeter@jabber.org</jid>
    <uri>https://stpeter.im/</uri>
  </author>

  <revision>
    <version>1.3.1</version>
    <date>2022-03-22</date>
    <initials>gl</initials>
    <remark>Fix incorrect reference to sipub namespace</remark>
  </revision>
  <revision>
    <version>1.3</version>
    <date>2017-11-29</date>
    <initials>XEP Editor (ssw)</initials>
    <remark>Deprecated by vote of the council.</remark>
  </revision>
  <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 <span class="ref"><link url="https://xmpp.org/extensions/xep-0066.html">Out-of-Band Data (XEP-0066)</link></span> <note>XEP-0066: Out of Band Data &lt;<link url="https://xmpp.org/extensions/xep-0066.html">https://xmpp.org/extensions/xep-0066.html</link>&gt;.</note> 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 <span class="ref"><link url="https://xmpp.org/extensions/xep-0095.html">Stream Initiation (XEP-0095)</link></span> <note>XEP-0095: Stream Initiation &lt;<link url="https://xmpp.org/extensions/xep-0095.html">https://xmpp.org/extensions/xep-0095.html</link>&gt;.</note> 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 <span class="ref"><link url="https://xmpp.org/extensions/xep-0082.html">XMPP Date and Time Profiles (XEP-0082)</link></span> <note>XEP-0082: XMPP Date and Time Profiles &lt;<link url="https://xmpp.org/extensions/xep-0082.html">https://xmpp.org/extensions/xep-0082.html</link>&gt;.</note>.</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 <span class="ref"><link url="https://xmpp.org/extensions/xep-0065.html">SOCKS5 Bytestreams (XEP-0065)</link></span> <note>XEP-0065: SOCKS5 Bytestreams &lt;<link url="https://xmpp.org/extensions/xep-0065.html">https://xmpp.org/extensions/xep-0065.html</link>&gt;.</note> and <span class="ref"><link url="https://xmpp.org/extensions/xep-0047.html">In-Band Bytestreams (XEP-0047)</link></span> <note>XEP-0047: In-Band Bytestreams &lt;<link url="https://xmpp.org/extensions/xep-0047.html">https://xmpp.org/extensions/xep-0047.html</link>&gt;.</note>, 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 the <span class="ref"><link url="http://www.iana.org/">Internet Assigned Numbers Authority (IANA)</link></span> <note>The Internet Assigned Numbers Authority (IANA) is the central coordinator for the assignment of unique parameter values for Internet protocols, such as port numbers and URI schemes. For further information, see &lt;<link url="http://www.iana.org/">http://www.iana.org/</link>&gt;.</note> 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 <span class="ref"><link url="https://xmpp.org/registrar/">XMPP Registrar</link></span> <note>The XMPP Registrar maintains a list of reserved protocol namespaces as well as registries of parameters used in the context of XMPP extension protocols approved by the XMPP Standards Foundation. For further information, see &lt;<link url="https://xmpp.org/registrar/">https://xmpp.org/registrar/</link>&gt;.</note> (see &lt;<link url="https://xmpp.org/registrar/si-profiles.html">https://xmpp.org/registrar/si-profiles.html</link>&gt;). 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 <span class="ref"><link url="https://xmpp.org/extensions/xep-0147.html">XMPP URI Query Components (XEP-0147)</link></span> <note>XEP-0147: XMPP URI Query Components &lt;<link url="https://xmpp.org/extensions/xep-0147.html">https://xmpp.org/extensions/xep-0147.html</link>&gt;.</note>, the XMPP Registrar maintains a registry of queries and key-value pairs for use in XMPP URIs (see &lt;<link url="https://xmpp.org/registrar/querytypes.html">https://xmpp.org/registrar/querytypes.html</link>&gt;).</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 <span class="ref"><link url="https://xmpp.org/extensions/xep-0137.html">Publishing Stream Initiation Requests (XEP-0137)</link></span> <note>XEP-0137: Publishing Stream Initiation Requests &lt;<link url="https://xmpp.org/extensions/xep-0137.html">https://xmpp.org/extensions/xep-0137.html</link>&gt;.</note> 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/sipub'
      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/sipub'
      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 <span class="ref"><link url="https://xmpp.org/extensions/xep-0137.html">Publishing Stream Initiation Requests (XEP-0137)</link></span> <note>XEP-0137: Publishing Stream Initiation Requests &lt;<link url="https://xmpp.org/extensions/xep-0137.html">https://xmpp.org/extensions/xep-0137.html</link>&gt;.</note>, 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/sipub' 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>
