Skip to content

Commit b329260

Browse files
committed
Send data fully instead of the stream
1 parent 0f531ee commit b329260

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

start-daemon.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,13 @@ spawn({}, (err, ipfsNode) => {
4747
},
4848
'cat': (args, send) => {
4949
ipfsNode.files.cat(args, (err, res) => {
50-
send({err, res})
50+
let data = ''
51+
res.on('data', (d) => {
52+
data = data + d.toString()
53+
})
54+
res.on('end', () => {
55+
send({err, res: data})
56+
})
5157
})
5258
}
5359
}

testpage.html

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,12 @@ <h2>Cat content</h2>
7070
$catOutput.innerText = ''
7171
console.log('got some data')
7272
console.log(res)
73-
res.on('data', (data) => {
74-
$catOutput.innerText = $catOutput.innerText + data
75-
})
73+
// TODO should return a stream, but can't get the stream to be passed down
74+
// correctly...
75+
// res.on('data', (data) => {
76+
// $catOutput.innerText = $catOutput.innerText + data
77+
// })
78+
$catOutput.innerText = res
7679
})
7780
}, false)
7881
}

0 commit comments

Comments
 (0)