Send file hash directly to specific swarm peer

The title says it all, but I was wondering how I could send a hash of a file directly to another swarm peer using only ipfs. The use for this would be to send a file directly to another person that may be to large to transfer via other means. Or in my case, I want to share a hash of a file, where that file has a many hashes in it that “UserA” has uploaded. AND UserA wants to share all those files to someone, say “UserB” without having to send each file individually. I have a script already that given a list of hashes, it gets those files from ipfs. I have looked into those experimental features of IPFS P2P and P2P Http Proxy, but I don’t know how I would use them. I am pretty new to the networking terms and ideas, but I have one idea on how I could get this to work, I just would also like to hear people ideas to learn more and discuss how viable is my idea. I am using go-ipfs, running ubuntu, with a private ipfs network. Users I would share files directly to would be within the private network

If you want to inform userB about a hash, so that they can then retrieve it, you can have userB subscribe to a pubsub topic and then send the hash using that topic.

Otherwise, you can use IPFS cluster to subscribe and push content to multiple ipfs peers: cluster.ipfs.io

Thank you for the fast reply! I got pubsub to work in my private network and I see that when I run ipfs pubsub sub <topic> the terminal is no longer available to use, because it’s now listening and waiting for content published under that topic. Obviously I can just do ipfs pubsub sub <topic> & to send it to the background and free up the terminal and still be able to see the output of someone publishing something under that topic. But now my question is how can I take that output and save/append it to a file. After I can save it to a file or can watch output to the terminal I can work with this easily. Also is that output already being saved somewhere, by any chance? I tried various redirecting methods and googling other ppls implementations, but I couldn’t find anything.

Have you tried ipfs pubsub sub <topic> >> subscription.txt &, or ipfs pubsub sub <topic> | tee subscription.txt ?

1 Like

Oh no I haven’t but I just tried your suggestion of ipfs pubsub sub <topic> >> subscription.txt & and that is exactly what I was looking for thank you so much for the help and the super fast reply!!

1 Like