Code Monkey home page Code Monkey logo

Comments (5)

vasco-santos avatar vasco-santos commented on May 27, 2024

Hi @Abhay-2811
It looks like you are using older version of node.js. You can see support for TransformStream in https://developer.mozilla.org/en-US/docs/Web/API/TransformStream#browser_compatibility and therefore this package required Node 18+ per https://github.com/web3-storage/ipfs-car/blob/main/package.json#L61

from ipfs-car.

Abhay-2811 avatar Abhay-2811 commented on May 27, 2024

Thanks for the response, i upgraded the node version and it worked.
A new doubt btw
TypeError [ERR_INVALID_ARG_TYPE]: The "transform.writable" property must be an instance of WritableStream. Received type string ('./b.car')
Can you help me understand "instance of WritableStream"

from ipfs-car.

Abhay-2811 avatar Abhay-2811 commented on May 27, 2024

Code:

`
import { CarIndexedReader } from '@ipld/car/indexed-reader'
import { recursive as exporter } from 'ipfs-unixfs-exporter'

const reader = await CarIndexedReader.fromFile('./a.car')
const roots = await reader.getRoots()

const entries = exporter(roots[0], {
async get (cid) {
const block = await reader.get(cid)
return block.bytes
}
})

for await (const entry of entries) {
if (entry.type === 'file' || entry.type === 'raw') {
console.log('file', entry.path, entry.content)
} else if (entry.type === 'directory') {
console.log('directory', entry.path)
}
}
`

Error:
Screenshot 2023-03-22 at 12 48 38 PM

from ipfs-car.

vasco-santos avatar vasco-santos commented on May 27, 2024

Hi @Abhay-2811
Could we get access to the CAR file you trying to unpack?

It can be possible that reader.get returns undefined. I could get a packed CAR working fine with:

import { CarIndexedReader } from '@ipld/car/indexed-reader'
import { recursive as exporter } from 'ipfs-unixfs-exporter'

const reader = await CarIndexedReader.fromFile('./a.car')
const roots = await reader.getRoots()

// @ts-ignore
const entries = exporter(roots[0], {
  async get (cid) {
    const block = await reader.get(cid)
    return block?.bytes
  }
})

for await (const entry of entries) {
  if (entry.type === 'file' || entry.type === 'raw') {
    console.log('file', entry.path, entry.content)
  } else if (entry.type === 'directory') {
    console.log('directory', entry.path)
  }
}

from ipfs-car.

vasco-santos avatar vasco-santos commented on May 27, 2024

Hi @Abhay-2811
Could we get access to the CAR file you trying to unpack?

It can be possible that reader.get returns undefined. I could get a packed CAR working fine with:

import { CarIndexedReader } from '@ipld/car/indexed-reader'
import { recursive as exporter } from 'ipfs-unixfs-exporter'

const reader = await CarIndexedReader.fromFile('./a.car')
const roots = await reader.getRoots()

// @ts-ignore
const entries = exporter(roots[0], {
  async get (cid) {
    const block = await reader.get(cid)
    return block?.bytes
  }
})

for await (const entry of entries) {
  if (entry.type === 'file' || entry.type === 'raw') {
    console.log('file', entry.path, entry.content)
  } else if (entry.type === 'directory') {
    console.log('directory', entry.path)
  }
}

from ipfs-car.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.