Published
Edited
Nov 11, 2020
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
ipfs = await IPFS.create()
Insert cell
Insert cell
Insert cell
file = ipfs.add(new Blob(['hello world']))
Insert cell
Insert cell
{
let content = '';
const decoder = new TextDecoder();
const cid = new CID('Qmf412jQZiuVUtdgnB36FXFX7xg5V6KEbSJ4dpQuhkLyfD');
for await (const chunk of ipfs.cat(cid)) {
content += decoder.decode(chunk);
}
return content;
}
Insert cell
Insert cell
files = {
const entries = ipfs.addAll([
{ path: 'dir' }, // diretory
{ path: 'dir/hello', content: new Blob(['hello world']) },
{ path: 'dir/bye', content: new Blob(['bye']) }
]);

const files = {};
for await (const entry of entries) {
files[entry.path] = entry;
yield files;
}
return files;
}
Insert cell
Insert cell
entries = {
let entries = [];
for await (const entry of ipfs.ls(files.dir.cid)) {
entries = [...entries, entry];
yield entries;
}
return entries;
}
Insert cell
Insert cell
Insert cell
hello = await ipfs.dag.put({
hello: "world"
})
Insert cell
Insert cell
Insert cell
hi = await ipfs.dag.put(
{ hello: "wold" },
{
format: "dag-cbor",
hashAlg: "sha3-512"
}
)
Insert cell
Insert cell
Insert cell
await ipfs.dag.get(hello)
Insert cell
ipfs.dag.get(hello, { path: "hello" })
Insert cell
Insert cell
Insert cell
Insert cell
ipfs.dag.get(greetings, { path: "/" })
Insert cell
Insert cell
await ipfs.dag.get(greetings, { path: "/hi/hello"})
Insert cell
Insert cell
mail = await ipfs.dag.put({
message: "hello world",
attachment: file.cid
})
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more