source
What Will I Learn?
- You will learn how to create an IPFS node.
- You will learn how to keep the IPFS node connected to the network constantly.
- You will learn how you can distribute your photos or files with IPFS.
Requirements
- An Ubuntu Server (Digitalocean, AWS etc.)
- A few sample photos to keep in IPFS.
Difficulty
- Basic/Intermediate
What is IPFS
IPFS is a peer-to-peer protocol where each node stores a collection of hashed files, images, videos etc. It is a distributed peer-to-peer file system which aims to transfer files at high speed and security and to make it impossible to interfere from the outside due to its distributed structure.
Download & Run an IPFS Node
- Go Programming Language must be installed on your ubuntu server. If it is not installed, you can easily install it with the following command.
sudo apt-get install golang-go -y
- Download the Go-IPFS software with wget to create a node. You can check the versions on this site Currently the latest version is 0.4.14.
wget https://dist.ipfs.io/go-ipfs/v0.4.14/go-ipfs_v0.4.14_linux-386.tar.gz
- You have to extract the archive with the following command.
tar xvfz go-ipfs_v0.4.14_linux-386.tar.gz
- Now you need to run following commands to install the IPFS to the server globally.
cd go-ipfs
sudo ./install.sh
- Let's initialize an IPFS node.
ipfs init
- After IPFS is initialization, you can run the IPFS node with the following command.
ipfs daemon
How to run an IPFS Node Forever (Crash Prevention)
If the IPFS server crashes due to any connection problem, it is necessary to restart it automatically. Ubuntu Service is the best solution for cases like this.
You can start to create a service with the following commands.
cd /lib/systemd/system/
nano ipfs.service
Paste the following codes. This allows to automatically restart the iPFS server in the event of an crash.
[Unit]
Description=IPFS
[Service]
ExecStart=/usr/local/bin/ipfs daemon
Restart=always
User=root
Group=root
[Install]
WantedBy=multi-user.target
Upload a file to IPFS
To upload a file to your IPFS server, you have to send an HTTP POST request to the server you created.
- Here is an example with Postman
I used steemia.net address. This is an IPFS server I set up for Steemia app. You will use your server address. Here is an example address.
167.99.XXX.XXX/api/v0/add
The http post request will respond to the Name, Size and Hash of the file you uploaded.
With this hash, you can access your file via IPFS gateway.
https://gateway.ipfs.io/ipfs/ {HASH}
https://gateway.ipfs.io/ipfs/QmaJVawuxkDnKxE6tFDT1V6xVjag3wDCG2BVBDjfwEwkLJ
Posted on Utopian.io - Rewarding Open Source Contributors
Thanks for the contribution.
Chat with us on Discord.Need help? Write a ticket on https://support.utopian.io.
[utopian-moderator]
Hey @deathwing, I just gave you a tip for your hard work on moderation. Upvote this comment to support the utopian moderators and increase your future rewards!
.
To be honest I'm still not sure about this issue 😁
We're using IPFS in Steemia app and our server only keep our own files. I'm still researching IPFS, don't forget to inform me when you learned 🙄😅Hello @crokkon,
Hey @hsynterkr! Thank you for the great work you've done!
We're already looking forward to your next contribution!
Fully Decentralized Rewards
We hope you will take the time to share your expertise and knowledge by rating contributions made by others on Utopian.io to help us reward the best contributions together.
Utopian Witness!
Vote for Utopian Witness! We are made of developers, system administrators, entrepreneurs, artists, content creators, thinkers. We embrace every nationality, mindset and belief.
Want to chat? Join us on Discord https://discord.me/utopian-io