File Download with WebTorrent
| <html> | |
| <body> | |
| <script src="https://cdn.jsdelivr.net/webtorrent/latest/webtorrent.min.js"></script> | |
| <script> | |
| var client = new WebTorrent() | |
| client.add('https://webseed.btorrent.xyz/juanpabloaj/other-page.torrent', function (torrent) { | |
| // Got torrent metadata! | |
| console.log('Client is downloading:', torrent.infoHash) | |
| torrent.files[0].getBlobURL(function(err, url) { | |
| if (err) return console.log(err) | |
| var a = document.createElement('a') | |
| a.target = '_blank' | |
| a.download = torrent.files[0].name | |
| a.href = url | |
| a.textContent = 'Download ' + torrent.files[0].name | |
| document.body.appendChild(a) | |
| }) | |
| }) | |
| </script> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment