You can use si-filetransfer, I used it to send the file, but it seems not as fast as I want. it sends in-bind file data, so it will be a little slower, it might be worth considering SOCKET5 bytestream (out-bind), but I have not tried it before.
the send demo file, the send () method parameter is slightly different, because I change it to fit my application, but basically it is the same. frame like this
// get Strohe.Connection getStropheConnection().si_filetransfer.send(file.id, fullJid, sid, file.filename, file.size, filetype, function(err) { if(err) { // err happen return; } // when codes comes here,mean your peer agree to receive your file // and we will use open to tell your peer you are going to send file // open: function (to, sid, bs, cb) getStropheConnection().ibb.open(fullJid, sid, '4096', function(err) { if(err) { // err happen with open return; } // code comes here, you can send data // call data method to send every peach of your file data // data: function (to, sid, seq, data, cb) file.seq = 0; // the file sequence getStropheConnection().ibb.data(fullJid, sid, file.seq, d0, function(err) { if(err) { // err happen with data return; } // repeat sending data util finish // call close tell your peer the file sending is finish // close: function (to, sid, cb) getStropheConnection().ibb.close(fullJid, sid, function(err) { if(err) { // err happen with close return; } }.bind(this)); }.bind(this)); }.bind(this)); }.bind(this));
and to get
_ibbReceiveFileCb : function(type, from, sid, data, seq, blocksize) { switch(type) { case "open": break; case "data": break; case "close": // every data through base64 encode, and 3 byte turn to 4 byte // compare receive size and file size make sure receive all data var resize = Math.ceil(file.blocksize * (file.seq + 1) / 4) * 3; var size = file.size; if(resize >= size) { // receive all data } else { // not receive all data } break; default: throw new Error("shouldn't be here."); } },
Sorry for not being able to give the full code, because it contains other code, for example, some kind of JSON object for storing data that might confuse you. fairly simple framework