How do I save a file to IPFS?

The way you interact with IPFS today is through a command-line interface. This can be a new experience to non-programmers, so I’ve written this step-by-step guide to upload your first file to the IPFS¹.

Step 1: Download and Install IPFS for your Platform

This one is easy, just follow this link to IPFS’ website and download.

Step 2: Move the Executable File to its Proper Location

You just downloaded a compressed folder. Now we must extract the contents, and place the ipfs file in the $PATH / %PATH% (Read this on PATH if confused). Instructions begin to differ between Mac/Linux and Windows operating systems:

For Mac/Linx:

After downloading, unpack the archived folder, and move the ipfs file somewhere in your $PATH . To do this via Terminal:

sudo mv ipfs /usr/local/bin/ipfs

For Windows:

After downloading, unzip the archive, and then cut ipfs.exe and paste somewhere in your %PATH% . You can also complete this via Command Prompt:

[Win + "cmd" -> right-click -> Run as Administrator]

C:\Users\yourName\Downloads>move .\go-ipfs\ipfs.exe C:\Windows

Step 3: Initialize IPFS

Great job so far! At this point you must open your command-line interface to continue. On a Mac, search for terminal , for Windows, search for cmd .

Now, confirm that you have properly moved the executable file by typing ipfs and hitting Return. You should see the following:

USAGE

ipfs - Global p2p merkle-dag filesystem.

...

Everything is installed properly, so it is time to init your IPFS repository². Type: ipfs init and hit Return. You will see something similar to this:

$ ipfs init

initializing ipfs node at /Users/yourName/.ipfs

generating 2048-bit RSA keypair...done

peer identity: Qmcpo2iLBikrdf1d6QU6vXuNb6P7hwrbNPW9kLAH8eG67z

to get started, enter:



ipfs cat /ipfs/QmYwAPJzv5CZsnA625s3Xf2nemtYgPpHdWEz79ojWnPbdG/readme

Go ahead and follow the instructions: copy and paste ipfs cat /ipfs/QmY...bdG/readme and you should see something like the following³.

Hello and Welcome to IPFS!



██╗██████╗ ███████╗███████╗

██║██╔══██╗██╔════╝██╔════╝

██║██████╔╝█████╗ ███████╗

██║██╔═══╝ ██╔══╝ ╚════██║

██║██║ ██║ ███████║

╚═╝╚═╝ ╚═╝ ╚══════╝



If you're seeing this, you have successfully installed

IPFS and are now interfacing with the ipfs merkledag!

Step 4: Add a File to IPFS

Now we’re ready to add our first file to IPFS! 🎉

They certainly do!

First, in the terminal, you want to "change directories” to get to the folder where your files reside. To change directories, type cd c:/yourPathHere (video tutorial here). I’m going to grab a folder called rare in my Pictures folder.

I’m going to add to IPFS the folder storing the picture to the left ( rare.jpg ) and another sample.

See how easy this is below:

$ ipfs add rare -r

added QmUbTW9iDRz4XgbHc62viUDSM76i1n52frG8HqqyarfMQk rare/XXX.jpg

added QmRuzPpc1tjJ5TbhG7B2Ato8LtaY2DK2Y5DMWWb29cqFF5 rare/rare.jpg

added QmdNMBVqQJ9baQDAJMUwci8LzVK2a52cTLEHoinaKFEdFY rare

What you see above is a pathway (i.e. a link) to the parent folder rare , and direct links to the child objects.

Step 5: Pin your File to IPFS

Next, we’re going to pin the files we added to IPFS to our local storage. Presumably these files already exist on our machine, and by pinning the file, other nodes on the IPFS network know they can access the file from our machine. Below I pin the rare directory:

$ ipfs pin add QmdNMBVqQJ9baQDAJMUwci8LzVK2a52cTLEHoinaKFEdFY

pinned QmdNMBVqQJ9baQDAJMUwci8LzVK2a52cTLEHoinaKFEdFY recursively

Step 6: Connect your IPFS Machine to the Network

In this next step, we will introduce your machine to the IPFS network. This allows other participants on the network to listen to your machine, to retrieve files from your machine, and for you to access files on others’ machines⁴.

Type the following to connect to the network:

$ ipfs daemon

Initializing daemon...

Open another terminal (or Command Prompt), and take a look at who is connecting to your machine:

$ ipfs swarm peers

Protocol Labs, the company that maintains IPFS, has a number of bootstrapping nodes that are actively looking for new content placed on the network.

Further, Protocol Labs maintains a HTTP -> IPFS gateway, and you can access any one of your files from their website, where they have mounted the IPFS system on their HTTP URL: https://ipfs.io/ipfs/[yourHash] .

Check out my file above, fully loaded on IPFS: https://ipfs.io/ipfs/QmRuzPpc1tjJ5TbhG7B2Ato8LtaY2DK2Y5DMWWb29cqFF5

Step 7: Don’t Forget to Close the Daemon