Can i upload a file by p2p protocol

Only find the doc of http protocol to upload a file https://docs.ipfs.io/reference/api/http/#api-v0-add
can i upload a file by p2p protocol?

Yes. You can upload a file using either go-ipfs or js-ipfs (which would let you add the file from the browser) from the computer you wish to upload the file from.

Thanks very much, but it have to spawn a node and upload a file.
what i want to do is build a ipfs sdk, it can discovery pub ipfs nodes and upload file to these nodes by p2p protocol.

Right, but browsers don’t currently ship with support for IPFS built in like they do with support for HTTP. I think the easiest thing to do would be to essentially bootstrap an IPFS node in the browser using HTTP to download js-ipfs and then connect to the IPFS network in the browser to add the file to the network.

Thanks again, I am working on go-ipfs. After days study, it need to modify go-ipfs to support p2p upload file. And now, we trying to do.

You cannot push a file to a random node.

Why are you constrained to use a p2p protocol (and what protocol)? The (HTTP) API is the current interface to interact with a go-ipfs node.

As a side note, IPFS Cluster HTTP API is also exposed via libp2p and has also has an /add endpoint:

From: https://cluster.ipfs.io/documentation/configuration/#the-api-section

1 Like