Open
Description
Describe the bug
let { Peer, BlockStore } = require('../js-dag-service/dist/index')
let { setupLibP2PHost } = require('../js-dag-service/dist/setup/index')
let { MemoryDatastore } = require('interface-datastore')
const fs = require("fs");
const store = new BlockStore(new MemoryDatastore())
const main = async () => {
// Bring your own libp2p host....
const host = await setupLibP2PHost()
const lite = new Peer(store, host)
await lite.start()
let content = fs.createReadStream('./a.txt');
var source = [
{
path: "bar",
content: content,
},
];
var data = await lite.addFile(source, { format: "raw", hashAlg: "sha2-256" })
const cid = data.cid
const data2 = await lite.getFile(cid)
fs.writeFile("b.txt", data2, "text", function (err) {
if (err) {
console.log(err);
} else {
console.log("The file was saved!");
}
});
await lite.stop()
}
main()
file size
-rw-rw-r-- 1 8725848 Aug 26 17:17 a.txt
-rw-rw-r-- 1 1710 Aug 26 17:25 b.txt
To Reproduce
Steps to reproduce the behavior:
- git clone js-dag-service and create a dist folder
- run the above code like 'node index.js'
Expected behavior
A file b.txt should have the content of file a.txt
Desktop :
- OS: ubuntu 18.04.4
Nodejs
v12.18.3
Thank you for any help
Metadata
Assignees
Labels
No labels
Activity