What is IPFS?
A brief introduction to the InterPlanetary File System.
Overview
The InterPlanetary File System, more commonly shortened as IPFS, is a hypermedia and peer-to-peer data and file sharing protocol. An easy way to think about IPFS is as a distributed alternative to HTTP and HTTPS. Information in IPFS is content addressed, rather than location addressed, allowing data to be stored based on the contents of such data, rather than the name or location of the data. For an example, let's compare how we would access a text file, example.txt
, over HTTP vs IPFS.
HTTP
In HTTP, to access our example text file example.txt
, you need to know the data's name and the data's location. Let us pretend that example.txt
is hosted on a server with the IP 127.0.0.1
, and is available over Port 80
.
When you look at how our example data of the example.txt
text file is accessed over HTTP, we can break it down into the protocol of HTTP
, the location of 127.0.0.1:80
, and the name of example.txt
. This is a simple example of addressing by name and location.
IPFS
In IPFS, to access our example text file example.txt
, you need to know the data's Content Identifier (CID). For information on how you obtain an IPFS CID, please see the below section, Getting an IPFS CID. For this sample, our example.txt
text file as the IPFS CID of QmWATWQ7fVPP2EFGu71UkfnqhYXDYH566qy47CnJDgvs8u
. This is the only piece of information needed to access our data.
When you look at how our example data of the example.txt
text file is accessed over IPFS, it only requires the data's Content Identifier since IPFS is based on content addressing. Rather than pointing to a location and name like in HTTP, IPFS creates an identifier based on the contents of the data. Because IPFS is based on content addressing, this also means that if two people have the same example.txt
, they will have an identical Content Identifier.
IPFS can also address entire directories. Assume we have a directory called Example
, that has our text file inside of it at Example/example.txt
. By adding our entire directory to IPFS, our content can be retrieved by specifying the path of our file within the directory, after the CID.
Getting an IPFS CID
To complete an IPFS Pin Orchestration Request, first you need to have an IPFS CID of the content you wish to manage. This next step assumes you do not already have an IPFS CID, if you do you may skip this step. Assuming you do not already have an IPFS CID, first create a sample text file for testing. You can name this whatever you like and write anything you wish inside, but for this example we will call the text file example.txt
with the contents of Hello World
.
Now we need to add our new example.txt
file to IPFS. Assuming you have IPFS installed on your local machine, you just need to add the file using ipfs add
.
When successful, the returned output from ipfs add
will confirm that the content has been added, and will provide a CID of the newly added content.
Last updated