Home | 简体中文 | 繁体中文 | 杂文 | 知乎专栏 | Github | OSChina 博客 | 云社区 | 云栖社区 | Facebook | Linkedin | 视频教程 | 打赏(Donations) | About
知乎专栏多维度架构微信号 netkiller-ebook | QQ群:128659835 请注明“读者”

21.5. Infura IPFS

21.5.1. 上传文件

			
neo@MacBook-Pro /tmp % cat hello.txt 
http://www.netkiller.cn

neo@MacBook-Pro /tmp % curl "https://ipfs.infura.io:5001/api/v0/add?pin=false" \
    -X POST \
    -H "Content-Type: multipart/form-data" \
    -F file=@"hello.txt"          
{"Name":"hello.txt","Hash":"QmToi4pgQH4LQX8wGMt5H8EV2dA7hD8S2EccRpd8YGUgac","Size":"32"}
			
			

21.5.2. 查看文件

			
neo@MacBook-Pro /tmp % curl "https://ipfs.infura.io:5001/api/v0/cat?arg=QmToi4pgQH4LQX8wGMt5H8EV2dA7hD8S2EccRpd8YGUgac" 
http://www.netkiller.cn
			
			

21.5.3. 下载文件

			
neo@MacBook-Pro /tmp % curl -s "https://ipfs.infura.io:5001/api/v0/get?arg=QmToi4pgQH4LQX8wGMt5H8EV2dA7hD8S2EccRpd8YGUgac&archive=true" -o hello.tgz

neo@MacBook-Pro /tmp % tar zxvf hello.tgz 
x QmToi4pgQH4LQX8wGMt5H8EV2dA7hD8S2EccRpd8YGUgac

neo@MacBook-Pro /tmp % cat QmToi4pgQH4LQX8wGMt5H8EV2dA7hD8S2EccRpd8YGUgac
http://www.netkiller.cn			
			
			

21.5.4. 创建目录

			
neo@MacBook-Pro /tmp % curl "https://ipfs.infura.io:5001/api/v0/files/mkdir?arg=/netkiller"

neo@MacBook-Pro /tmp % curl "https://ipfs.infura.io:5001/api/v0/files/stat?arg=/netkiller"        
{"Hash":"QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn","Size":0,"CumulativeSize":4,"Blocks":0,"Type":"directory"}			
			
			

21.5.5. 查看文件状态

			
neo@MacBook-Pro /tmp % curl "https://ipfs.infura.io:5001/api/v0/files/stat?arg=/netkiller"        
{"Hash":"QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn","Size":0,"CumulativeSize":4,"Blocks":0,"Type":"directory"}			
			
			

21.5.6. 查看IPFS版本号

			
neo@MacBook-Pro ~/workspace % curl "https://ipfs.infura.io:5001/api/v0/version"
{"Version":"0.4.14","Commit":"","Repo":"6","System":"amd64/linux","Golang":"go1.10"}