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