What is the InterPlanetary File System or IPFS?
IPFS is a hypermedia protocol similar to HTTP. In fact, IPFS intends to someday replace HTTP. Both are protocols for transferring files from a server to a client over the internet. These protocols can transfer any type of file from text to video. When you browse the web you are using HTTP to download HTML files from servers all over the world.
The advantage of using IPFS is data immutability and speed.
Files on IPFS are given a generated hash value. A hash is kind of like a fingerprint for a file. Here is an example of a IPFS hash value:
Data Speed & Resilience
Traditionally, HTTP has followed to simple client server model. A computer (the client) in Seattle request a file from a computer (the server) in New York City.
This can be slow or unreliable for many reasons. For example:
- New York is far away from Seattle. It just takes longer to communicate due to distance even at the speed of light.
- There could be lots and lots of clients asking the computer in New York for files.
- The computer in New York can only serve so many clients.
- Or maybe the computer in New York is not simply not turned on.
IPFS is a peer-to-peer protocol somewhat similar to Bittorrent. When I download a file some of that data can be shared with others. So maybe someone else in Seattle also downloaded that file from the server in New York. I could just download it from them. If a file is very popular then many people will have copies to share. This takes the load off the New York server and distributes it. Even if the server is turned off, I might still access the file. And I would be confident that nobody tampered with the file because of the immutability feature.
Working with IPFS
Go to ipfs.io and download the software for your platform of choice. Follow the instruction for installation. The official docs are great but I will very quickly summarize them below.
IPFS needs to initialized before we can use it.
Start the Daemon
The IPFS daemon must be running for us to use the system. Run this command in a separate terminal.
Adding a File
This is my cat. Her name is Miss Hiss. She is a bit of a stinker.
We are going to add this cat picture to IPFS. The file name is
cat_in_bag.pngAdding the file is quite simple.
ipfs add cat_in_bag.png
IPFS will output the the hash.
added QmR1VhhtXVvzw5zc12wj1CtohKh6DU7Y1MHpqRdhmrTZ7Y cat_in_bag.png`
Getting a File
Getting a file is pretty simple too. With this command the file you download will have the name
QmR1VhhtXVvzw5zc12wj1CtohKh6DU7Y1MHpqRdhmrTZ7Y but it is still our cute cat pic.
ipfs get QmR1VhhtXVvzw5zc12wj1CtohKh6DU7Y1MHpqRdhmrTZ7Y
As stated in the title, this is just a very brief introduction to IPFS. There is much more to learn. For further reading I would recommend: