Skip to content

Instantly share code, notes, and snippets.

@flaviocopes
Created November 23, 2018 11:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flaviocopes/0843a32f8e68965b094a6b55f8f1f652 to your computer and use it in GitHub Desktop.
Save flaviocopes/0843a32f8e68965b094a6b55f8f1f652 to your computer and use it in GitHub Desktop.
PeerJS photo sharing example - sender
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