IPFS - Essentials

pwangdu(57)
Published in
#ipfs
Words
351
Reading
2 min
Listen
Play
9y

IPFS - Interplanetory File System

This is a sequel to my previous about post IPFS

Introduction

IPFS is a peer to peer hypermedia protocol inspired by peer to peer sharing by bittorrent and file system management by git. It promises and infact makes the web permanent and you can wtch the philosophy behind it in this awesome video.

Installation

Please refer to Installation Instructions for installing IPFS on your system.

You can check if IPFS is instaled correctly using following command

ipfs version

This should print the version of IPFS installed on your system.

For this tutorial I am using my windows 10 machine and have unpacked the ipfs archive and added the archived folder to my path.

To get started with IPFS we need to initialize it.

Initializing IPFS

ipfs init initializes the IPFS.

IMG01

After successful initialization it provides a unique identity. These unique ids help locate shared IPFS folders and files over network. The output suggests that we should try using cat command with ipfs.

Fetch and Display content

ipfs cat /ipfs/QmS4ustL54uo8FzR9455qaxZwuMiUhyvMcX9Ba8nUH4uVv/readme

The command above displays the contents of readme file as follows

02

This file was dileverd from QmS4ustL54uo8FzR9455qaxZwuMiUhyvMcX9Ba8nUH4uVv to my machine after I ran that command.

Browse what is shared and is available

ipfs ls QmS4ustL54uo8FzR9455qaxZwuMiUhyvMcX9Ba8nUH4uVv lists all the files shared by QmS4ustL54uo8FzR9455qaxZwuMiUhyvMcX9Ba8nUH4uVv.

03

The files are listed with the corrosponding hash values of the content. This means duplicate content even if name differently will resolve to same hash value.

Sharing your local files and folders with IPFS

ipfs add -r 2048-master

This command adds the folder to ipfs and returns a hash value with which it can be accessed. In our example 2048-master contains a HTML and JavaScript based game and we have just hosted it on IPFS however to make it accessible ipfs deamon needs to be running on the host. Let's start it with following command in seperate terminal.

ipfs daemon

Once the daemon is up an running we should be able to use the hash provided by ipfs add command and access the 2048 Game. (Don't get distracted by the game)

It will be served in the browser with address

Useful Links:

IPFS - Essentials | Ecency