Skip to content
This repository has been archived by the owner on Mar 10, 2020. It is now read-only.

Add URLs directly #109

Closed
jbenet opened this issue Nov 11, 2015 · 8 comments
Closed

Add URLs directly #109

jbenet opened this issue Nov 11, 2015 · 8 comments
Assignees

Comments

@jbenet
Copy link
Contributor

jbenet commented Nov 11, 2015

ipfs add in the cli can add from the filesystem (makes sense, given the cli context). I think the js api on the browser should be able to add from the web (makes sense, given the web context).

So, i would like this to work:

ipfs.add('http://i.imgur.com/YTSpZdP.gif', function(err, res) { ... })

I think it should work on Node, too, given that node is js and already straddles the boundaries between unix and the web.

There is also an argument to be made re adding this natively to the go-ipfs cli too. (i.e. making the cmds lib accept files on http as just other files)

@jbenet
Copy link
Contributor Author

jbenet commented Nov 11, 2015

I'll make something very cool if someone can implement this for me

@dignifiedquire
Copy link
Contributor

Is there a need for this to be in the core of the library, or could it be simply a small package adding this feature on its own?

@jbenet
Copy link
Contributor Author

jbenet commented Nov 11, 2015

I think this should be in the api bindings library, yes. I want it to be this easy for users to work with:

<script src="..."></script>
var ipfs = ipfsApi(...)
ipfs.add("http://...")

this is the web equivalent of making ipfs add <unix-file> work in the cli. in the most basic sense, a user's first experience with ipfs is adding a file, and that should be as easy as possible. in the web that means http files.

> install-ipfs
> ipfs --api <api-endpoint> add <file>

this is porcelain.

this api bindings, like the golang cli, or git itself, are really "toolkits" including both plumbing and porcelain commands. they're piecing together a bunch of small commands and making them easy to use.

@dignifiedquire
Copy link
Contributor

in the most basic sense, a user's first experience with ipfs is adding a file, and that should be as easy as possible. in the web that means http files.

Fully agreed, but is js-ipfs-api this first place where they come into contact with it, or wouldn't that be more js-ipfs for most people. I understood this api as just a basic building block, while js-ipfs is the equivalent in user facing functionality to go-ipfs.

Also before this is implemented the question is do you plan to add it to go-ipfs, because that way there would not be the need to implement this here, instead we could just forward it to go-ipfs.

@mappum
Copy link
Contributor

mappum commented Nov 12, 2015

You can already do something very close to this using request:

ipfs.add(request('http://...'), function (err, res) { ... })

(This means only in browserify, but that is how most people are using js-ipfs-api anyway)

@jbenet
Copy link
Contributor Author

jbenet commented Nov 16, 2015

@mappum nice, useful.

i think since http requests are already done in the api, this extra porcelain isn't a big cost (it's not adding a library, etc), it's merely making something simpler for the user.

Also before this is implemented the question is do you plan to add it to go-ipfs, because that way there would not be the need to implement this here, instead we could just forward it to go-ipfs.

maybe we should add it to go-ipfs as well -- not sure yet. but for this, no we should still do it on the api -- because it means a different execution context. the browser might be in a completely different machine (with different cookies, etc) than the ipfs node.

@dignifiedquire dignifiedquire self-assigned this Nov 16, 2015
dignifiedquire added a commit to dignifiedquire/js-ipfs-api that referenced this issue Nov 16, 2015
@jbenet
Copy link
Contributor Author

jbenet commented Nov 23, 2015

I'll make something very cool if someone can implement this for me

As promised: https://github.com/jbenet/http2ipfs-web -- thanks again!

@daviddias
Copy link
Contributor

sweet!

@xicombd you might be interested on this for your pocket clone :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants