Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.

Commit 1fa4185

Browse files
authored
chore: use ipfs.addAll for streams (#46)
`ipfs.add` is for single items, `ipfs.addAll` is for multiple. In the next ipfs release we will start enforcing this so update the example to call the correct method.
1 parent 4be9336 commit 1fa4185

File tree

1 file changed

+7
-5
lines changed
  • examples/browser-add-readable-stream/src

1 file changed

+7
-5
lines changed

examples/browser-add-readable-stream/src/index.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,14 @@ const main = async () => {
110110
}
111111
})
112112

113-
const data = await ipfs.add(stream)
114-
115-
// The last data event will contain the directory hash
116-
if (data.path === directory) {
117-
return data.cid
113+
for await (const data of ipfs.addAll(stream)) {
114+
// The last data event will contain the directory hash
115+
if (data.path === directory) {
116+
return data.cid
117+
}
118118
}
119+
120+
throw new Error('Could not find directory in `ipfs.addAll` output')
119121
}
120122

121123
const addFile = async (name, content, directory) => {

0 commit comments

Comments
 (0)