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

Support `FileList` as input for the `seed` method #153

Merged
merged 1 commit into from Oct 19, 2014

Conversation

@valeriangalliat
Copy link
Contributor

valeriangalliat commented Oct 18, 2014

The W3C FileList object has no map method, thus it needs to be converted to an array before using.

Otherwise I got input.map is not a function with the following code:

var WebTorrent = require('webtorrent')

var client = new WebTorrent()

// `input` is a file input
input.onchange = function (e) {
  client.seed(e.target.files, function (torrent) {
    console.log('Torrent info hash:', torrent.infoHash)
  })
}
The W3C `FileList` object has no `map` method, thus it needs to be converted to an array before using.
@feross

This comment has been minimized.

Copy link
Member

feross commented Oct 19, 2014

Thanks for catching this. I never caught this because my drag-drop module returns a proper array, not a FileList. We need better browser tests to catch things like this going forward.

This is a good start, but it's also a partial fix because the lines that create the file buffer (https://github.com/feross/webtorrent/pull/153/files#diff-168726dbe96b3ce427e7fedce31bb0bcR208) will not access the file data from the FileList correctly. I'll fix this.

feross added a commit that referenced this pull request Oct 19, 2014
Support `FileList` as input for the `seed` method
@feross feross merged commit 022f17d into webtorrent:master Oct 19, 2014
1 check failed
1 check failed
continuous-integration/travis-ci The Travis CI build failed
Details
@valeriangalliat valeriangalliat deleted the valeriangalliat:patch-2 branch Oct 20, 2014
@feross

This comment has been minimized.

Copy link
Member

feross commented Oct 20, 2014

@valeriangalliat Okay, you should now be able to seed a FileList correctly as of webtorrent 0.10.1.

@valeriangalliat

This comment has been minimized.

Copy link
Contributor Author

valeriangalliat commented Oct 20, 2014

Awesome, thank you!

@feross

This comment has been minimized.

Copy link
Member

feross commented Oct 22, 2014

@valeriangalliat - sorry, there was a bug in 0.10.1. Give 0.10.2 a try!

@valeriangalliat

This comment has been minimized.

Copy link
Contributor Author

valeriangalliat commented Oct 22, 2014

No problem, I didn't have the time to try it yet. I'll give you feedback in the following days. :)

@lock lock bot locked as resolved and limited conversation to collaborators May 16, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.