Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a way to get the raw data from a file and embed it in a page? #1346

Closed
ki4jgt opened this issue Apr 2, 2018 · 2 comments
Closed

Is there a way to get the raw data from a file and embed it in a page? #1346

ki4jgt opened this issue Apr 2, 2018 · 2 comments

Comments

@ki4jgt
Copy link

@ki4jgt ki4jgt commented Apr 2, 2018

What version of WebTorrent?
Current -- using CDN
What operating system and Node.js version?
Windows -- in browser
What browser and version? (if using WebTorrent in the browser)
Mozilla 59
What did you expect to happen?
N/A
What actually happened?

I'm working on a P2P video-sharing platform in the browser. I would like to read a txt file -- containing video information -- and then display its contents within the page.

@KayleePop

This comment has been minimized.

Copy link
Contributor

@KayleePop KayleePop commented Apr 7, 2018

// file is a webtorrent file object
file.getBuffer(function (err, buffer) {
  if (err) throw err
  let text = buffer.toString('utf8')
  console.log(text) //or render to DOM
})
@feross

This comment has been minimized.

Copy link
Member

@feross feross commented May 15, 2018

Thanks for sharing a code example, @KayleePop :)

@ki4jgt There are more methods of accessing file data in the docs: http://webtorrent.io/docs

@feross feross closed this May 15, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Aug 13, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.