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

chore: use ipfs.addAll for streams #46

Merged
merged 1 commit into from
Sep 30, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions examples/browser-add-readable-stream/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,14 @@ const main = async () => {
}
})

const data = await ipfs.add(stream)

// The last data event will contain the directory hash
if (data.path === directory) {
return data.cid
for await (const data of ipfs.addAll(stream)) {
// The last data event will contain the directory hash
if (data.path === directory) {
return data.cid
}
}

throw new Error('Could not find directory in `ipfs.addAll` output')
}

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