IPFS初体验(环境搭建,私有网络环境搭建,API演示)

原文地址:https://blog.csdn.net/wen942467928/article/details/79377402

 

基本命令

$ ipfs init

$ ipfs daemon

$ ipfs cat ahash

$ ipfs ls ahash

$ ipfs id

$ echo "This is some data" | ipfsblock put

 $ ipfs swarm peers

$ ipfs swarm connect

/ip4/98.207.107.204/tcp/4001/ipfs/QmVenSWgxVW4NVLCwBHTxXxuzNLaXTDoxUTqVxeaJM5avt

$ echo "ipfs rocks" > foo

$ ipfs add foo

$ ipfs pin ls --type=all

$ ipfs pin rm <foo hash>

$ ipfs pin rm -r <foo hash>        //宣布为垃圾,还可以读取该文件

$ ipfs repo gc                    //垃圾回收,回收完再也看不到该文件了

$ ipfs pin ls --type=all

 

$ ipfs name publish <that hash>                //制作ipns

Published to<your peer ID>: <that hash>    // /ipns/peerId会指向/ipfs/thathash

$ ipfs name resolve <your peer ID>

$ ipfs cat <your peer ID>

 

$ ipfs bootstrap list

$ ipfs bootstrap add

$ ipfs bootstrap rm

 

建立私有的IPFS网络

$ ipfs boostrap rm --all

$ ipfs bootstrap add <your peerID>

$ ipfs daemon

注意所有的peer节点重新设定peer之后还要重新启动ipfs 。

API演示

先用nginx做个代理转发

增加一个文件 /api/v0/add?arg=file

根据返回的哈希值查询该文件 /api/v0/cat?arg=<filehash>

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值