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

File path seeding problems #495

Closed
shime opened this issue Nov 28, 2015 · 6 comments
Closed

File path seeding problems #495

shime opened this issue Nov 28, 2015 · 6 comments

Comments

@shime
Copy link
Contributor

@shime shime commented Nov 28, 2015

I'm trying this one

var client = new WebTorrent()
client.seed('foo')

And getting back

Uncaught TypeError: fs.stat is not a function

Documentation clearly says that the seed method accepts file path as a string. What am I doing wrong?

JS Bin example

@shime

This comment has been minimized.

Copy link
Contributor Author

@shime shime commented Nov 28, 2015

I've overriden the method that was throwing that exception and got to

Uncaught Error: filesystem paths do not work in the browser

So it's currently not possible to seed anything that's outside input[file]?

@elad

This comment has been minimized.

Copy link

@elad elad commented Nov 30, 2015

Right, probably by (browser) design. Otherwise it would mean Javascript code could seed arbitrary files from your computer! :) I think at least Chrome's sandbox stops this type of access and requires explicit user intervention (the file input) to do it.

In other words, this isn't a bug and it's outside the scope of WebTorrent, IMO.

@ericwooley

This comment has been minimized.

Copy link
Contributor

@ericwooley ericwooley commented Nov 30, 2015

It might be a bug in chrome, or the documentation could be referring to when you are using webtorrent-hybrid, which allows you to read from the file system.

@elad

This comment has been minimized.

Copy link

@elad elad commented Nov 30, 2015

The API documentation isn't clear, but the examples before it distinguish between "in the browser" and "in node.js." In the browser you must have user intervention (drag and drop, for example). In node.js, you don't.

As for Chrome, it's definitely not a bug. Even the dead/deprecated/abandoned HTML5 file system API would only let you access files inside the sandbox rather than arbitrary files on the machine.

feross added a commit that referenced this issue Dec 2, 2015
Update README (Fix #495)
@feross

This comment has been minimized.

Copy link
Member

@feross feross commented Dec 2, 2015

Filesystem access is not allowed in the browser. Using a file path is only supported when using WebTorrent in node.js.

We should improve the error message that you get since Uncaught TypeError: fs.stat is not a function isn't helpful.

feross added a commit to webtorrent/create-torrent that referenced this issue Dec 2, 2015
In the browser, WebTorrent’s `client.seed()` function returns “Uncaught
TypeError: fs.stat is not a function” when passing in a file path,
because fs.readdir is defined by brfs (I think). Let’s check for
fs.stat instead.

For webtorrent/webtorrent#495 (comment)
feross added a commit to webtorrent/create-torrent that referenced this issue Dec 2, 2015
@feross

This comment has been minimized.

Copy link
Member

@feross feross commented Dec 2, 2015

The error message is fixed in create-torrent with these commits:

webtorrent/create-torrent@2d4f01e
webtorrent/create-torrent@1dc59e7

@lock lock bot locked as resolved and limited conversation to collaborators May 5, 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
4 participants
You can’t perform that action at this time.