Search code examples
javascriptxmppstrophe

Complete example of Strophe.js file transfer


I'm developing a chat web client (XMPP based) using Strophe.js. On server side I have an Openfire server.

I'm looking for a complete (and working) example of file transfer (xep-0096) using Strophe.js.

I know there is a plugin, named si-filetransfer, which should help in implementing this feature but documentation is missing. So it is not easy to understand how it works.

Here on StackOverflow I found only some incomplete post relating the matter, as for example: Save received files from xmpp Strophe si-filetransfer

Also on the web I didn't find any complete solution to my needs.

If there is another solution to achieve the above goal (file transfer in a JS client using XMPP protocol) it 's welcome!


Solution

  • Here below is a very simple chat demo written using jQuery and StropheJS with file transfer features. Implementation of file transfer is based on these two Strophe.js plugins:

    In addition, in order to allow the transfer of files greater than 65535 bytes it is also used a chunking algorithm.

    Here is the Plunker: http://plnkr.co/edit/fYpXo1mFRWPxrLlgr123

    P.S.: you have to deploy your own XMPP server and adapt the following code lines according to your configuration:

    var server = 'mydomain.com';
    var BOSH_SERVICE = 'http://127.0.0.1:7070/http-bind/';