Created
November 23, 2018 11:08
-
-
Save flaviocopes/0843a32f8e68965b094a6b55f8f1f652 to your computer and use it in GitHub Desktop.
PeerJS photo sharing example - sender
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.addEventListener('DOMContentLoaded', event => { | |
const peer = new Peer('sender', { host: 'localhost', port: 9000, path: '/' }) | |
const conn = peer.connect('receiver') | |
document.querySelector('input').onchange = function(event) { | |
const file = event.target.files[0] | |
const blob = new Blob(event.target.files, { type: file.type }) | |
conn.send({ | |
file: blob, | |
filename: file.name, | |
filetype: file.type | |
}) | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment