This repository was archived by the owner on Feb 12, 2024. It is now read-only.
This repository was archived by the owner on Feb 12, 2024. It is now read-only.
files.cat stream doesn't auto resume .on('data') #939
Closed
Description
I wrote this simple demo on jsbin, but somehow the content stream does not emit any data?
I would love to see such a simple demo here in the repo and I will submit a pull request if wanted to this repo
https://jsbin.com/covirovuxe/edit?html,output
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script src="https://unpkg.com/ipfs/dist/index.min.js"></script>
<script>
const node = new Ipfs()
node.on('ready', () => {
// Your node is now ready to use \o/
console.log('ready')
node.files.get('QmYwAPJzv5CZsnA625s3Xf2nemtYgPpHdWEz79ojWnPbdG', (err, data) => {
console.log(err, data)
data.on('data', (file) => {
console.log(file)
if(!file.content) return
// write the file's path and contents to standard out
file.content.on('data', function (chunk) {
console.log(chunk)
})
file.content.on('error', function (error) {
console.log(error)
})
file.content.on('end', function () {
console.log('no more data')
})
})
})
})
</script>
</body>
</html>