create account

Publishing to IPFS by sevcsik

View this thread on: hive.blogpeakd.comecency.com
· @sevcsik ·
$0.04
Publishing to IPFS
_I'm reposting this from my [blog](https://sevdev.hu/ipns/sevdev.hu), originally published at [June 26, 2016](https://sevdev.hu/ipns/sevdev.hu/posts/2016-06-26-publishing-to-ipfs.html)._

If you visited this site more than once in the past year, you might notice
that it started redirecting to a weird path, like this: `/ipns/sevdev.hu`.

The reason being that the site is now hosted on [IPFS], and the path
you are seeing is the IPFS path of the site, served by the HTTP gateway
of [go-ipfs]. So, what is this, and why it is a big deal?

<!-- TEASER -->

# The Interplanetary Filesystem

IPFS is a distributed, peer-to-peer, content-addressed filesystem. It's like
the lovechild of BitTorrent and Git. It makes it possible to make a file or
directory available on the network, where other nodes can access it
knowing only the hash of the content, but unaware of the location of the host.
This allows a transparent, infrastructure-agnostic and inherently redundant
data storage. The network is trustless, as it's impossible to change their
content without changing their address.

In this setup, the VPS behind sevdev.hu is just an IPFS node, with a HTTP
gateway to serve traditional web browsers. If the page is accessed natively
through an IPFS client, it could just be served by any other IPFS node
which holds a copy.

# Publishing files

To get started, just install [go-ipfs] and initialise your node with
`ipfs init`. This will generate a private key, and a corresponding peer ID,
which will identify your node over the peer-to-peer network. After that, the
daemon can be started by `ipfs daemon`.

Making a file available on IPFS is the easiest part. After installing
[go-ipfs] , just use `ipfs add <path>`. That doesn't transmit anything
to the network - it just calculates and stores the hash of the given
file. If any node looks for this specific hash in the future, your node
will serve it.

It's also possible to store trees, just like in Git. A tree's hash is composed
of the hash and path of the leaves, which allows us to publish a whole
directory recursively, with `ipfs add -r <path>`.

# Addressing

The `ipfs add` command outputs a friendly looking, base-58 hash, starting
with `Qm` for some reason. This file can be referenced by any node on the
network, using the path `/ipfs/<hash>`. As long as your node is up and
has a healthy connection, any node can access your content using this
path. There is a public gateway at the IPFS home page to try: 
`http://ipfs.io/ipfs/<hash>`.

Since paths are immutable, it's impossible to deliver updates to users.
That's why IPFS has a separate namespace at `/ipns/`, where mutable
names can be resolved. The concept is similar to Git branches -- they are
mutable pointers, as oppesed to commits, which are content-addressable,
immutable objects.

This namespace can use a number of name services to resolve IPFS resources.

# IPFS names

IPFS provides a built-in method to publish names on the peer-to-peer network.
Using your private key, you can publish a name, which points to an IPFS
content address. These names are stored in a DHT, and has to be republished
regularly (~12h) to stay alive.

IPFS names can be published by the `ipfs name publish <hash>` command, which
will publish the given hash under the node's peer ID. The content can be
referenced later with the path `/ipns/<peer id>`. There is also a commandline
tool, [ipns-pub] to conveniently publish to multiple names, without changing
the node configuration.

This is a self-contained, decentralised way of publishing content, but
practically it needs an always-on server with the private key on file, 
to be able to keep the name alive. According to folks on [#ipfs], this will
change in the future.

# DNS

Alternatively, the good ol' DNS can be used to resolve IPFS names. The
`dnslink=` TXT record should point to the IPFS path.

For example, here's the TXT record of the [IPFS website][IPFS]:

```
ipfs.io. 11 IN TXT "dnslink=/ipfs/QmTzQ1JRkWErjk39mryYw2WVaphAZNAREyMchXzYQ7c15n"
```

Because of that TXT record, the website can be accessed by the `/ipns/ipfs.io`
path, instead of an unfriendly peer ID.

# Using IPFS on today's web

Obviously, there is no native support for the IPFS protocol in web browsers.
This site, as well as the IPFS webite provides a HTTP gateway, that
conveniently maps IPFS paths to the document root, so they can be loaded in
a HTTP client without any modification.

This practice makes it possible to redirect every HTTP gateway to the local
node's gateway pretty easily, for example using the [IPFS station] extension.
That provides a seamless way to use  IPFS how it's meant to be used: using the
peer-to-peer network, without any knowledge of the original host.

[IPFS]: https://ipfs.io
[go-ipfs]: https://github.com/ipfs/go-ipfs
[ipns-pub]: https://github.com/whyrusleeping/ipns-pub
[#ipfs]: irc://chat.freenode.net/ipfs
[IPFS Station]: https://chrome.google.com/webstore/detail/ipfs-station/kckhgoigikkadogfdiojcblegfhdnjei
👍  , , , , , , , , , , , ,
properties (23)
authorsevcsik
permlinkpublishing-to-ipfs
categorydevelopment
json_metadata{"tags":["development","ipfs","p2p","decentralization","bittorrent","git"],"links":["http://ipfs.io/ipfs/","https://ipfs.io"]}
created2016-07-11 13:44:57
last_update2016-07-11 13:44:57
depth0
children9
last_payout2016-08-24 00:30:12
cashout_time1969-12-31 23:59:59
total_payout_value0.029 HBD
curator_payout_value0.009 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length4,991
author_reputation70,278,902,050
root_title"Publishing to IPFS"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id78,685
net_rshares512,813,711,847
author_curate_reward""
vote details (13)
@amihay ·
properties (23)
authoramihay
permlinkre-publishing-to-ipfs
categorydevelopment
json_metadata{}
created2016-08-08 01:09:27
last_update2016-08-08 01:09:27
depth1
children0
last_payout2016-08-24 00:30:12
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length11
author_reputation1,271,791,839,323
root_title"Publishing to IPFS"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id673,937
net_rshares-398,930,597
author_curate_reward""
vote details (5)
@hotwings ·
Nice to have you around!

Here are some tips if you're not aware of them already:

 Secure your account: https://steemit.com/steemit-guides/@pfunk/your-steem-account-is-worth-money-how-to-secure-it-with-a-new-owner-key-to-keep-it-yours-forever
    
Verify your account and build your reputation: https://steemit.com/steem/@tuck-fheman/verified-accounts--reputation-system
   
Contribute with your own contents: https://steemit.com/steem/@grittenald/copy-paste-steal-cite-your-sources, and https://steemit.com/steemit/@pfunk/lets-discuss-verification-of-user-accounts-posting-previous-work-to-prevent-impersonation
   
Properly tagging your posts, especially when your content is #NSFW or for #test only
   
Know how Steemit works: https://steemit.com/steemit/@donkeypong/still-confused-by-steem-steem-dollars-and-steem-power-the-power-plant-analogy
properties (22)
authorhotwings
permlinkre-sevcsik-publishing-to-ipfs-20160711t134528100z
categorydevelopment
json_metadata{"tags":["NSFW","test","development"],"links":["https://steemit.com/steemit-guides/@pfunk/your-steem-account-is-worth-money-how-to-secure-it-with-a-new-owner-key-to-keep-it-yours-forever"]}
created2016-07-11 13:45:27
last_update2016-07-11 13:45:27
depth1
children0
last_payout2016-08-24 00:30:12
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length848
author_reputation-468,374,953,755
root_title"Publishing to IPFS"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id78,688
net_rshares0
@iamsubbu ·
How you can serve as a ipfs service provider, means how can i earn money from ipfs hosting for others ?
properties (22)
authoriamsubbu
permlinkre-sevcsik-publishing-to-ipfs-20170901t100009957z
categorydevelopment
json_metadata{"tags":["development"],"app":"steemit/0.1"}
created2017-09-01 10:00:15
last_update2017-09-01 10:00:15
depth1
children1
last_payout2017-09-08 10:00:15
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length103
author_reputation8,740,731,126
root_title"Publishing to IPFS"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id13,536,222
net_rshares0
@sevcsik ·
At the moment you can't, but Filecoin will provide this functionality when launched.
properties (22)
authorsevcsik
permlinkre-iamsubbu-re-sevcsik-publishing-to-ipfs-20171218t144311512z
categorydevelopment
json_metadata{"tags":["development"],"app":"steemit/0.1"}
created2017-12-18 14:43:12
last_update2017-12-18 14:43:12
depth2
children0
last_payout2017-12-25 14:43:12
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length84
author_reputation70,278,902,050
root_title"Publishing to IPFS"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id24,033,382
net_rshares0
@moderators · (edited)
What am I doing wrong ?
```
$ ipfs daemon
$ ipfs add -r /Users/m/Desktop/img_test 

added QmcDQDePjtXyS28aRFHuSXBiGifcL8jdihhDvvt3nteYww img_test/IMG_8831.jpg
added QmeT1dXQsGVGDgt5A2vQLDbMS4sPr1KsZG3vBKGnANRvtM img_test/IMG_8834.jpg
added QmbAqf4gCDqJAaWN5ZfaMz4yoBEkL2Z9ivcusHy8wpXTbA img_test

$ ipfs name publish QmbAqf4gCDqJAaWN5ZfaMz4yoBEkL2Z9ivcusHy8wpXTbA img_test
Error: Unknown Command "QmbAqf4gCDqJAaWN5ZfaMz4yoBEkL2Z9ivcusHy8wpXTbA"

```
properties (22)
authormoderators
permlinkre-sevcsik-publishing-to-ipfs-20180207t182953230z
categorydevelopment
json_metadata{"tags":["development"],"app":"steemit/0.1"}
created2018-02-07 18:29:54
last_update2018-02-07 18:30:27
depth1
children3
last_payout2018-02-14 18:29:54
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length449
author_reputation251,411,212,123
root_title"Publishing to IPFS"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id35,721,982
net_rshares0
@coriander ·
you don't need to specify a path:
`ipfs name publish QmbAqf4gCDqJAaWN5ZfaMz4yoBEkL2Z9ivcusHy8wpXTbA`
properties (22)
authorcoriander
permlinkre-moderators-re-sevcsik-publishing-to-ipfs-20180207t204430166z
categorydevelopment
json_metadata{"tags":["development"],"app":"steemit/0.1"}
created2018-02-07 20:44:30
last_update2018-02-07 20:44:30
depth2
children2
last_payout2018-02-14 20:44:30
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length100
author_reputation127,229,595
root_title"Publishing to IPFS"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id35,746,263
net_rshares0
@moderators ·
just 
$ ipfs name publish  img_test ?

ps: can i create directory ?
properties (22)
authormoderators
permlinkre-coriander-re-moderators-re-sevcsik-publishing-to-ipfs-20180207t222122033z
categorydevelopment
json_metadata{"tags":["development"],"app":"steemit/0.1"}
created2018-02-07 22:21:21
last_update2018-02-07 22:21:21
depth3
children1
last_payout2018-02-14 22:21:21
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length67
author_reputation251,411,212,123
root_title"Publishing to IPFS"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id35,762,853
net_rshares0
@thunderbirdman ·
HI, I am having trouble using IPFS and Dsound.. do you know how to install and use IPFS?  "settings" in Dsound do not do anything and there are no instructions
properties (22)
authorthunderbirdman
permlinkre-sevcsik-publishing-to-ipfs-20170921t184529274z
categorydevelopment
json_metadata{"tags":["development"],"app":"steemit/0.1"}
created2017-09-21 18:45:27
last_update2017-09-21 18:45:27
depth1
children0
last_payout2017-09-28 18:45:27
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length159
author_reputation11,208,941,844
root_title"Publishing to IPFS"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id15,548,876
net_rshares0