What is the right way to request content from an IPFS node (with its PeerId)? With or without the CID. For example, a IPFS node A knows that content X is on node B but node A may not know the CID for the content X, how node A can communicate with node B and ask node B to retrieve and send the content X to him/her?
Hi @emclab!
From an application standpoint, one thing you can do is to make the HTTP gateway for node B public.
Now, anyone(including node A) can get the content from node B. But the question is how we can do that?
Now, there can be a number of situations.
-
You know the CID for the content: So, you can easily get the data by referencing the CID.
-
You know the CID of the folder in which the content resides. Then you can fetch the folder and get the file from there.
As IPFS uses content addressing, without the CID, the nodes can’t tell each other what they want.
Summing up, you need to have some identifier(CID) through which you can get to your desired content.
I think it’s actually easier to use a ipns instead of a cid. The ipns can be updated, when you upload new data to a folder.
The ipns can be added to a domain name, this way you can query it with any DNS client. (Keyword DNSLink).
That’s all pretty low level, but works fine for a user with advanced knowledge (on the sending side).
If you got a CID/IPNS or a Domain name with DNSLink you can either receive the data via a local ipfs client via ipfs pin add $cid
for example or you can browse the data via a http gateway like the one from Cloudflare:
For example those both urls does exactly this, first one with a public domain name and the second is the current ipfs.