What is IPFS?
IPFS is a distributed system for storing and accessing files, websites, applications, and data.
“The InterPlanetary File System (IPFS) is a protocol and peer-to-peer network for storing and sharing data in a distributed file system. IPFS uses content-addressing to uniquely identify each file in a global namespace connecting all computing devices.”
Decentralized File Storage
Any file to be saved online can be locally encrypted then uploaded on this network. Then the file is broken into pieces and is stored on different devices on the network, maintaining 51% redundancy to avoid data loss. To keep track of each piece we use smart contracts based on the Blockchain technology.
Distributed Decentralized Data Storage is a type of data storage network that depends upon the IPFS (InterPlanetary File System)Protocol to save the files. The files are encrypted on the client-side before upload. Anything uploaded on the IPFS network generates a hash. This hash is stored on the server. This server is also running an IPFS daemon to access the IPFS network. When a file is to be uploaded it is first sent to the server, running PHP backend, The file is encrypted here and passed on to the IPFS daemon, which then uploads this file to IPFS network and returns a hash to refer to the file, which then gets stored on the server for further reference.
Distributed Hash Tables
A Distributed Hash Table (DHT) is a distributed system that provides access to the key-value store. The store is spread over the participating nodes and offers excellent performance and scalability. DHTs are used widely in peer-to-peer systems to coordinate and maintain metadata about the system.
IPFS Nodes:
Every node on the network is identified using a NodeID which is nothing but the hash of its public key. Everyone on the network can store files on their local storage and they are incentivized to do so. Each node maintains a DHT which is used to find out Ids of other peers on the network and what data those peers can serve.
How does IPFS Work?
- A file added to IPFS is split up into blocks and are linked together via a unique cryptographic hash
- Each IPFS node stores content.
- The network locates the closest nodes storing the content behind the hash
- Files are named using a naming system called IPNS
Getting Started with IPFS:
To get on the IPFS network we can install IPFS from the Official Website.
>ipfs init
initializing IPFS node at /users/user/.ipfs
This command initializes IPFS configuration files and generates a new keypair using 2048 bit-RSA.
Peer identity is: QmTo1oMgGEH6Ym3H1xF55U7q4bexd5288YmEJjubDqVmKn
For getting started you’ve to enter:
ipfs cat /ipfs/QmS4ustL54uo8FzR9455qaxZwuMiUhyvMcX9Ba8nUH4uVv/readme
You’ll see something like this:
Adding files to IPFS
Create a demo folder anywhere on your device and add in a couple of files. You can add any type of file like images, videos, etc.
Suppose your folder name is “my-ipfs”. So to push these files and navigate into this folder and then run the following command:
$ ipfs add -r .
For running single file use the following command:
$ ipfs add <filename.extension>
added QmUx6PWeRAPxCTqmK4eGq95KnvPCJwNhfU1cgw5RWCEG8y my-ipfs/cats/cat.jpeg
added QmZkMyLFKAQqRXer1MExU3vnfAFmxCN7rFkpmsUQBG81UN
my-ipfs/cats/cat2.jpeg
added QmTmtiurZozG98k7QnTvbQ2i95b3VPou3By8HQm8TRHEKq my-ipfs/cats
added QmPHxSJX9VeFgkXoESJ29zLoCVh6GP1yCkb68fu97drSts my-ipfs
the image has been added to IPFS and now you can access it.
You’ll get a unique hash of a given file. Every file and folder will have a unique hash value.
ipfs ls QmeoPDguuLaYsZXnniL5Be7t9hmbU55XU6B8/cats
Accessing your files online
To access your files online, you’ve to connect your node to the IPFS network. For that, you have to run the IPFS daemon.
$ ipfs daemon
You can access them by copying the hash and running it in your browser.
localhost:8080/ipfs/QmeoPDguuLaYsZXnniL5Be7t9hmbU55XU6B8/cats/cat.jpg
CONCLUSIONS
With more data being created in 2017 than all the previous 5,000 years of humanity put together, and the amount of data exponentially increasing, data storage solutions will be more and more important. IPFS is hoping to be at the forefront of this. The biggest benefit of ipfs is its low operating costs. For example, the cost of storing 1TB of data on AWS is approximately $20. Using ipfs, it is possible to bring down the cost of storage approximately ten times also the data is safe and securely stored unless 51% of the network goes down or is attacked which is highly unlikely and extremely tough to do which means 100% safety and security.