Transfer file via libp2p

Hi guys, Is there a way to transfer file (approx. 100mb) between nodes on the same network?

I’m very new about network things. I followed getting started documentation and also chat example but couldn’t understand what I am supposed to do.

If I can change sendData in rw.WriteString(fmt.Sprintf("%s\n", sendData)) with my file, does it work?

What is a file ?
It’s just a binary blob. So just send the content of the file and your file is sent.

If I can change sendData in rw.WriteString(fmt.Sprintf(“%s\n”, sendData)) with my file, does it work?

Idk, try it !
Even if does that is very dumb :smiley: because you are loading the complete file in memory and then copying a bunch of time before finaly sending it.

You should use io.Copy because it “streams” file.

1 Like