ipfs02
IPFS-day02
其他常用操作
添加文件并用文件夹包裹
ipfs add xxx -w把內容快取到本地,并提供给他人。官网文档
ipfs pin add QmT7TX5vGmFz86V8cDkPuTss1vp4qTXeaziGZrjdJhURFfadd本身是递归的,所有的子目录都回被 pin 住。可以用ipfs pin ls看看本地 pin 的内容。
js-ipfs-api
文本上传&获取
上传
ipfs.files.add(Buffer.from(value, 'utf-8'))
.then(files => console.log(files[0].hash))
.catch(e => console.error(e));
获取
ipfs.files.cat(inputHash, (err, file) => {
if (err) {
throw err;
}
let message = file.toString('utf8');
console.log(message);
})
图片上传&展示
上传
let fr = new FileReader();
fr.onloadend=(e) => {
// 文件加载完成, 开始上传
ipfs.add(Buffer.from(fr.result))
.then(result => {this.setState({imgHash: result[0].hash})})
.catch(e => console.error(e))
};
// 加载文件
fr.readAsArrayBuffer(file)
展示
<img src={`http://127.0.0.1:8080/ipfs/${imgHash}`} alt="黑马程序员"/>
音频/视频上传&展示
<div id="player__holder">
<h3>多媒体Hash: {mediaHash}</h3>
<video id="player" controls src={`http://127.0.0.1:8080/ipfs/${mediaHash}`}>
<p>Your browser does not support playing video. </p>
</video>
{/*<audio width='100%' controls>*/}
{/*<source src={`http://127.0.0.1:8080/ipfs/${mediaHash}`} />*/}
{/*</audio>*/}
</div>
本地files操作
- ls
- cp
- rm
通过antd优化页面
ipfs跨平台客户端(electron)
https://github.com/ipfs-shipyard/ipfs-desktop/releases
ipfs02的更多相关文章
- ipfs02笔记
IPFS-day02 其他常用操作 添加文件并用文件夹包裹 ipfs add xxx -w 把內容快取到本地,并提供给他人.官网文档 ipfs pin add QmT7TX5vGmFz86V8cDkP ...
随机推荐
- shell命令查看某文件夹下的文件个数
shell命令查看某文件夹下的文件个数 2010-06-25 17:05:15| 分类: shell |字号 订阅 1.查看某文件夹下文件的个数: ls -l |grep "^-&qu ...
- Python使用dict和set
dict Python内置了字典:dict的支持,dict全称dictionary,在其他语言中也成为map,使用键-值(key-value)存储,具有极快的查找速度. 假设要根据同学的名字查找对应的 ...
- React Router 4 的使用(2)
Route Rendering Props 对于给定的路由如何渲染组件,有三种选项:component.render.children.你可以查看 <Route> 的文档来获取更多的信息, ...
- Oracle db file parallel write 和 log file parallel write 等待事件
一. db file parallel write等待事件 引自如下blog: http://oradbpedia.com/wiki/Wait_Events_-_db_file_parallel_wr ...
- oracle中特殊字符替换
replace语法: REPLACE(char,search_string,[replacement_string]) 在replace中,每个search_String 都会被replacement ...
- Oracle树形结构数据---常见处理情景
Oracle树形结构数据---常见处理情景 1.查看表数据结构 SELECT * FROM QIANCODE.TREE_HIS_TABLE T ORDER BY T.NODE_LEVEL; ...
- shell脚本中 [-eq] [-ne] [-gt] [-lt] [ge] [le]
-eq //等于 -ne //不等于 -gt //大于 (greater ) -lt //小于 (less) -ge //大于等于 -le //小于等于 在linux 中 命令执行状态:0 为真,其他 ...
- 第13届景驰-埃森哲杯广东工业大学ACM程序设计大赛--G-旋转矩阵
链接:https://www.nowcoder.com/acm/contest/90/G 来源:牛客网 1.题目描述 景驰公司自成立伊始,公司便将“推动智能交通的发展,让人类的出行更安全,更高效,更经 ...
- Delphi 版FindWindow 和 FindWindowEx 的语法和用法
FindWindow(lpClassName, {窗口的类名}lpWindowName: PChar {窗口的标题}): HWND; {返回窗口的句柄; 失败返 ...
- poj_1306_Combinations
Computing the exact number of ways that N things can be taken M at a time can be a great challenge w ...