Skip to content

Not able to add or get a file greater than 256 KB #385

Open
@jainsameeksha729

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:

  1. git clone js-dag-service and create a dist folder
  2. 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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions