Transferring files on home network

I have raspberry pi and Windows PC both running ipfs. Both are connected to home network ie. same wifi. I need to share files between them using ipfs. I’m very new to ipfs, please help me out with this.

I’d recommend looking at the Getting Started page on ipfs.io if you haven’t already.

Here’s an example of how you’d share files between computers assuming ipfs is already installed in the path on each machine, the repos have been initialized ipfs init, and there’s a daemon running on each computer (ipfs daemon).

Source:
ipfs add path/to/file or ipfs add -r /path/to/directory. You might want to consider the -w option to wrap the content in another directory to preserve the top level’s original name.

Receiver:
ipfs get <hash> or ipfs pin add <hash> or ipfs cat <hash> where <hash> is the multihash output from the command above run on the source.

Note that unless you send someone else the content’s hash it’s unlikely they will be able to retrieve the files as well, though I think it’s possible to sniff the DHT traffic that your machines send out to the swarm to potentially get it without you explicitly sharing it. If you wanted to set up a private network, see this discussion.

Thanks for the help, I used the command and I got the file, my only doubt it, when I used ipfs get
It said : saving file(s) to
Where is the file stored in my computer?
The physical location of my file?

echo $HOME should tell you the default extraction location. But if you changed directory before running ipfs get then the file will wind up in the relevant working directory. Independent of the working directory, you can add the -o option to define a different download location, e.g.: ipfs get HASH -o /local/path/to/filename … or: ipfs get HASH/filename -o /local/path/to/filename

PS: there’s also a way to link two nodes, and they will then auto-pin each other’s files (“IPFS cluster”). Once you feel at home on the IPFS, you might want to try that out:

https://dist.ipfs.io/#ipfs-cluster-ctl

EDIT: an alternate to ipfs get would be ipfs cat HASH > /local/path/to/filename

However, with these two commands (get and cat) the file will not be pinned to your second node, it will only be cached until you run garbage collection with ipfs repo gc. To permanently add an object to your second node, you have to run ipfs pin add HASH first. Use it like ipfs pin add -r HASH if it’s a directory with files in it. After that operation, you can then ipfs get or ipfs cat.

2 Likes