From 4b7eb0196e28a4cfae3125c2a1c9c4c70052d931 Mon Sep 17 00:00:00 2001 From: samsont Date: Mon, 11 Apr 2016 18:08:19 -0400 Subject: [PATCH] Allow sending of metadata with file If you send a file: added the ability to send metadata about the file. The functionality was already in place, just added a spot for the additional data. --- peer.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/peer.js b/peer.js index 23723454..6c0beab4 100644 --- a/peer.js +++ b/peer.js @@ -263,7 +263,7 @@ Peer.prototype.handleDataChannelAdded = function (channel) { this._observeDataChannel(channel); }; -Peer.prototype.sendFile = function (file) { +Peer.prototype.sendFile = function (file, metadata) { var sender = new FileTransfer.Sender(); var dc = this.getDataChannel('filetransfer' + (new Date()).getTime(), { protocol: INBAND_FILETRANSFER_V1 @@ -272,7 +272,8 @@ Peer.prototype.sendFile = function (file) { dc.onopen = function () { dc.send(JSON.stringify({ size: file.size, - name: file.name + name: file.name, + additionalData : metadata })); sender.send(file, dc); };