在B站看了黎跃春老师的教学视频,结合网上的资源和自己的操作整理的笔记,知识无价,感谢分享!
"em" at Station B to see Mr. Lejongchun's teaching video, combining online resources with notes from his own operation, knowledge is invaluable, thank you for sharing!
cd 1127/demo
create-react-app ipfs_img
cd ipfs_img
atom https://www.jianshu.com/p/
npm start
拷贝到App.js
Copy to App.js
npm install --save-dev ipfs-api
或者
npm install --save ipfs-api
Npm install--save-dev ipfs-api
or
npm install-save ipfs-api
卸载指令
Unmount Command
npm uninstall --save-dev ipfs-api
npm uninstall --save ipfs-api
npm start
const ipfsAPI=require('ipfs-api');
const ipfs=ipfsAPI({host: 'localhost',port: '5001',protocol: 'http'});
- reader.readAsDataURL(file);上传图片路径。
- reader.readAsArrayBuffer(file)
- 上传图片
hash 即是上传到IPFS的图片的HASH地址,this.setState({imgSrc: hash})将hash保存到状态机变量imgSrc中。
Hash is the HASH address for uploading images to IPFS, where this.setState ({imgSrc:hash}) saves the ash to the status machine variable imgSrc.
注册有任何问题请添加 微信:MVIP619 拉你进入群
打开微信扫一扫
添加客服
进入交流群
发表评论