[IPFS Tutorial #3] - Using the IPFS Command Line Interface
What Will I Learn?
- How to Initialize and configure a local IPFS node
- Upload files to your local IPFS node with CLI
- Track files from your local IPFS node with CLI
Requirements
- Laptop or Desktop Computer (Windows, Linux or Mac)
- IPFS CLI
- Several different files to upload (gif, mp4, .png etc.)
Difficulty
- Intermediate
Initialize a Local IPFS Node
Initializing the IPFS daemon is very simple, just download the compatible version of your computer and install it.
After installation is complete, start the daemon with the command line.
ipfs init
Enter the ipfs init command to start the daemon. This will create a local IPFS node on your machine.
After ipfs is initialized, it will create a readme file. Enter the following command to view the readme file.
ipfs cat /ipfs/QmS4ustL54uo8FzR9455qaxZwuMiUhyvMcX9Ba8nUH4uVv/readme
./readme
You can explore other files(about, help, quick-start, security-notes) in there.
Configure the IPFS Node
The daemon configuration file is kept as a json file. Run the following command to view this configuration.
ipfs config show
To edit the configuration, run the following command. for example, you can change ports for API or Gateway.
"API": "/ip4/127.0.0.1/tcp/5001",
"Gateway": "/ip4/127.0.0.1/tcp/8080"
If you want to allow or deny HTTP POST requests, you can also set this with the config file.
"HTTPHeaders": {
"Access-Control-Allow-Headers": [
"X-Requested-With"
"Range"
]
"Access-Control-Allow-Methods": [
"GET,POST"
]
"Access-Control-Allow-Origin": [
"*"
]
}
Upload files to your local IPFS node with CLI
To upload a file to IPFS, run the IPFS daemon with the following command.
ipfs daemon
You can create a folder on the desktop for the files you want to upload. I created a folder named 'examples'
I have added a few files to the examples folder to upload them to the IPFS node
To upload a file to the IPFS node, open a command prompt in the directory where the file is located and run the following command in CLI.
$ ipfs add FILE_NAME
# Examples
$ ipfs add image.png
$ ipfs add note.txt
With the HASH returned from the CLI, you can access your file via the local IPFS gateway.
http://localhost:8080/ipfs/ {HASH}
Track files from your local IPFS node with CLI
Tracking files from the local IPFS node is very easy with the CLI. To read a file, you only need HASH of that file. You can read the file with ipfs cat FILE_HASH command.
ipfs cat FILE_HASH
ipfs cat QmfDCcLFMFCASvuWuLzFeQcVyFb8Pj3cpPvLPFWozbTETY
An example is shown below. I uploaded a Markdown file to the IPFS node and tried to read it with "ipfs cat" command.
Curriculum
Leave [IPFS Tutorial #3] - Using the IPFS Command Line Interface to:
Read more #utopian-io posts
Best Posts From Hüseyin TERKİR
We have not curated any of hsynterkr's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.
More Posts From Hüseyin TERKİR
- My 1st Steem Anniversary | Let's meet at SteemFest³
- My first time participating in a Blockchain Hackathon
- Ulogs.org Improvements - Moving to Heroku
- ULOG: Working With React #1
- [Steemia] - App Updates
- Kripto Para Uzmanları(!)
- KnackSteem API Updates
- Bobby Bagpack - Great Bagpack for Travelers
- Steemia Pay - Send and receive money with STEEM
- [Ionic Tutorial #2] - Barcode Scanning
- Introducing Steemia Pay - STEEM Payment App
- [Ionic Tutorial #1] - QR Code Generator App
- [Steemia] - App Updates
- [IPFS Tutorial #4] - Upload and Stream Videos via IPFS
- [Steemia] - App Updates
- [Steemia] - App Updates
- Delete Comment via SteemConnect
- [IPFS Tutorial #3] - Using the IPFS Command Line Interface
- [IPFS Tutorial #2] - Build a NodeJS app for IPFS
- [IPFS Tutorial #1] - Host Your Images Online Forever with IPFS