let buffer = require('buffer') var client = new WebTorrent() client.on('error', function (err) { console.error('ERROR: ' + err.message) }) // You can pass in a DOM node or a selector string! DragDrop('.drop-div', function (files, pos, fileList, directories) { console.log('Here are the dropped files', files) console.log('Dropped at coordinates', pos.x, pos.y) console.log('Here is the raw FileList object if you need it:', fileList) console.log('Here is the list of directories:', directories) client.seed(files, function (torrent) { console.log(torrent); console.log('Client is seeding ' + torrent.magnetURI) let t = ``; t += `Client is seeding ${torrent.magnetURI}`; t += `

Name: ${torrent.name}

`; t += `

Name: ${torrent.path}

`; var hexdata = torrent.torrentFile.toString('hex'); t += `

Torrent: ${hexdata}

`; t += `

`; t += `
Files hash
`; for (let h = 0; h < torrent._hashes.length; h++) { const hash = torrent._hashes[h]; t += `

${hash}

`; } t += `
Peers
`; for (let p = 0; p < torrent._peers.length; p++) { const peer = torrent._peers[p]; t += `

Peer: ${peer}

`; } t += `
Trackers
`; for (let r = 0; r < torrent.discovery._announce.length; r++) { const tracker = torrent.discovery._announce[r]; t += `

${tracker}

`; } $("#seed-result").html(t); }) })