首页
首页
文章目录
  1. 简介
  2. IPFS用法
    1. 安装ipfs
    2. 创建本地库(初始化本地库)
    3. 查看基本情况
    4. 查看帮助
    5. 具体操作顺序

ipfs的研究与使用

简介

ipfs 是什么,ipfs全称为InterPlanetary File System, 简称IPFS,中文翻译为星际文件系统,或者全球文件系统。是一个旨在创建持久且分布式存储的共享文件的网络传输协议。它是一种内容可寻址的对等超媒体分发协议。在IPFS网络中的节点将构成一个分布式文件系统。

还有它是开源的。

github 地址:https://github.com/ipfs/ipfs

IPFS用法

安装ipfs

从github下载包,执行下面命令即可

1
2
tar xvfz go-ipfs.tar.gz
mv go-ipfs/ipfs /usr/local/bin/ipfs

创建本地库(初始化本地库)

1
ipfs init

执行后回出现以下信息:

1
2
3
4
5
6
initializing ipfs node at /Users/jbenet/.go-ipfs
generating 2048-bit RSA keypair...done
peer identity: Qmcpo2iLBikrdf1d6QU6vXuNb6P7hwrbNPW9kLAH8eG67z
to get started, enter:

ipfs cat /ipfs/QmYwAPJzv5CZsnA625s3Xf2nemtYgPpHdWEz79ojWnPbdG/readme

查看基本情况

1
ipfs cat /ipfs/QmYwAPJzv5CZsnA625s3Xf2nemtYgPpHdWEz79ojWnPbdG/readme

返回信息

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
Hello and Welcome to IPFS!

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

If you're seeing this, you have successfully installed
IPFS and are now interfacing with the ipfs merkledag!

-------------------------------------------------------
| Warning: |
| This is alpha software. use at your own discretion! |
| Much is missing or lacking polish. There are bugs. |
| Not yet secure. Read the security notes for more. |
-------------------------------------------------------

Check out some of the other files in this directory:

./about 关于
./help 帮助
./quick-start <-- usage examples 使用方法
./readme <-- this file 就是现在查看的文件
./security-notes 暂时没用

查看帮助

1
ipfs cat /ipfs/QmYwAPJzv5CZsnA625s3Xf2nemtYgPpHdWEz79ojWnPbdG/quick-start

返回信息:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# 0.1 - Quick Start

This is a set of short examples with minimal explanation. It is meant as
a "quick start".


Add a file to ipfs: 添加一个文件

echo "hello world" >hello
ipfs add hello


View it: 查看它

ipfs cat <the-hash-you-got-here>


Try a directory: 创建并添加一个目录

mkdir foo
mkdir foo/bar
echo "baz" > foo/baz
echo "baz" > foo/bar/baz
ipfs add -r foo


View things: 查看这个目录

ipfs ls <the-hash-here>
ipfs ls <the-hash-here>/bar
ipfs cat <the-hash-here>/baz
ipfs cat <the-hash-here>/bar/baz
ipfs cat <the-hash-here>/bar
ipfs ls <the-hash-here>/baz


References: 重定向

ipfs refs <the-hash-here>
ipfs refs -r <the-hash-here>
ipfs refs --help


Get:下载文件和对比文件

ipfs get <the-hash-here> -o foo2
diff foo foo2



Objects: 列出对象

ipfs object get <the-hash-here>
ipfs object get <the-hash-here>/foo2
ipfs object --help

Daemon:

ipfs daemon (in another terminal)
ipfs id


Network:

(must be online)
ipfs swarm peers
ipfs id
ipfs cat <hash-of-remote-object>



Mount:

(warning: fuse is finicky!)
ipfs mount
cd /ipfs/<the-hash-here>
ls



Tool: 工具

ipfs version
ipfs update
ipfs commands
ipfs config --help
open http://localhost:5001/webui



Browse: web浏览

webui:

http://localhost:5001/webui

video:

http://localhost:8080/ipfs/QmVc6zuAneKJzicnJpfrqCH9gSy6bz54JhcypfJYhGUFQu/play#/ipfs/QmTKZgRNwDNZwHtJSjCp6r5FYefzpULfy37JvMt9DwvXse

images:

http://localhost:8080/ipfs/QmZpc3HvfjEXvLWGQPWbHk3AjD5j8NEN4gmFN8Jmrd5g83/cs

markdown renderer app:

http://localhost:8080/ipfs/QmX7M9CiYXjVeFnkfVGf3y5ixTZ2ACeSGyL1vBJY1HvQPp/mdown

真实网络访问地址:

http://ipfs.io/ipfs/%E6%96%87%E4%BB%B6id
https://ipfs.io/ipfs/QmU1xVZoA4mGneuHfHgycuYQYBmFwKFdLeuvQ7tQPDucJk

具体操作顺序

  1. 安装(下载程序解压放到指定路径)
  2. 初始化本地库(ipfs init只有第一次需要执行)
  3. 启动(ipfs daemon)
  4. 浏览器打开127.0.0.1:5001/webui 对文件进行上传下载查看等操作。(也可以通过命令行操作)
  5. 配置文件保存在.ipfs/config 中可以对其端口进行修改。(也可以通过上方url进行更改)
  6. 查看通过web上传获取到id后 直接使用在浏览器输入ipfs.io/ipfs/文件id即可访问

最后上个图。

启动图片
webui图

End

支持一下
扫一扫,我会更有动力更新
  • 微信扫一扫
  • 支付宝扫一扫