Find out CID from IPFS Network before contents upload

How can I find out there is already an existing CID within IPFS network before I add new contents? So my problem is 2 fold

  1. I want to know the CID of contents before upload

  2. Find out from IPFS network that there is no other node hosting contents with same CID

I will really appreciate a response.

Use the --only-hash option for ipfs add along with whichever other add options you think are appropriate (e.g., --trickle for video). For example,

ipfs add --only-hash path/to/file

If the following command returns something, then there are other peers that say they can provide the root hash. Note that this doesn’t necessarily mean they can provide the entire DAG. For example, some of the nodes might have the root node of the DAG and the first part of a video file.

ipfs dht findprovs hash
1 Like