IPFS Explained — Upload and Retrieve Files on the Decentralized Web

IPFS Explained — Upload and Retrieve Files on the Decentralized Web

Derrk SamuelJune 6, 20267 min read
IPFS (InterPlanetary File System) is the backbone of decentralized storage in Web3. Learn how to install IPFS, add files to the network, retrieve them by hash, and pin them so they don't disappear.

What Is IPFS?

IPFS (InterPlanetary File System) is a peer-to-peer distributed file system that stores and retrieves content by its cryptographic hash rather than by location (like a URL).

Instead of asking "where is this file?", IPFS asks "what is this file?" — a content hash never changes, so you always get exactly what you requested. This is the foundation of NFT metadata storage, decentralized websites, and Web3 data permanence.


Install IPFS (Kubo — Go Implementation)

Linux/Ubuntu

wget https://dist.ipfs.tech/kubo/v0.27.0/kubo_v0.27.0_linux-amd64.tar.gz
tar -xvzf kubo_v0.27.0_linux-amd64.tar.gz
cd kubo
sudo bash install.sh

Verify:

ipfs --version

Initialize Your IPFS Node

ipfs init

This creates your node identity and config at ~/.ipfs/.

Your Peer ID (like an address on the IPFS network) is shown in the output.


Start the IPFS Daemon

ipfs daemon

Leave this running in a terminal (or run it as a systemd service).


Add a File to IPFS

ipfs add myfile.txt

Output:

added QmXyz123... myfile.txt

The QmXyz123... string is your file's Content Identifier (CID). This is how anyone on IPFS can retrieve your file.


Add a Folder

ipfs add -r ./my-folder/

This adds all files recursively and returns a CID for the folder root.


Retrieve a File by CID

ipfs cat QmXyz123...

This fetches and prints the file contents. To save it:

ipfs get QmXyz123... -o ./output-file.txt

Access Files via HTTP Gateway

If the IPFS daemon is running locally:

http://localhost:8080/ipfs/QmXyz123...

Via a public gateway (no local node required):

https://ipfs.io/ipfs/QmXyz123...
https://cloudflare-ipfs.com/ipfs/QmXyz123...

Public gateways are useful for sharing links with people who don't run IPFS nodes.


Pinning — Keep Files Available

By default, IPFS may garbage-collect files that aren't pinned. Pin a file to keep it:

ipfs pin add QmXyz123...

List your pinned files:

ipfs pin ls

Remove a pin:

ipfs pin rm QmXyz123...

Remote Pinning (Persistent Storage)

Your local node must stay online for files to be available. For permanent storage, use a pinning service:

These services keep your files pinned even when your node is offline.


IPFS in Web3 Context

NFT Metadata Example

Most NFT projects store metadata on IPFS:

{
  "name": "My NFT #1",
  "description": "A unique digital asset",
  "image": "ipfs://QmXyz123.../image.png",
  "attributes": [...]
}

The ipfs:// URI scheme ensures the metadata is content-addressed and tamper-proof.

Upload Metadata with Node.js

const { create } = require("ipfs-http-client");

const client = create({ url: "http://localhost:5001" });

const metadata = JSON.stringify({
  name: "My NFT #1",
  description: "IPFS-stored metadata",
  image: "ipfs://QmImageHash..."
});

const result = await client.add(metadata);
console.log("CID:", result.path);
// → QmMetadataHash...

Quick Reference

GoalCommand
Initialize nodeipfs init
Start daemonipfs daemon
Add fileipfs add file.txt
Add folderipfs add -r ./folder/
Retrieve by CIDipfs cat QmXyz...
Save locallyipfs get QmXyz... -o output
Pin fileipfs pin add QmXyz...
List pinsipfs pin ls
Check node infoipfs id
Check peersipfs swarm peers

IPFS is the foundation of most decentralized storage strategies in Web3 — understanding how it works is essential for anyone building dApps, NFT platforms, or censorship-resistant applications.

Also featured on TechDerks Insights

I write more takes like this one on my second blog — blockchain deep dives, security breakdowns, and builder tools.

Read more on TechDerks Insights
D

Derrk Samuel

Web3, crypto, and Linux PC insights — practical guides, security tips, mining setups, blockchain tools, and decentralized tech strategies for techs.

Discussion

Leave a comment

No comments yet. Be the first to start the discussion!