Reputation: 11957
I'm trying to create a reader from a .car file (Content Addressed Archive) using @ipld/car
. The documentation shows how to create a carReader
when files are small as per below:
import { CarReader } from '@ipld/car'
const inStream = fs.createReadStream('example.car');
// read and parse the entire stream in one go, this will cache the contents of
// the car in memory so is not suitable for large files.
const reader = await CarReader.fromIterable(inStream);
Question: If I have a file at C:\output.car
, and it's say 10GB and larger than my available RAM, how can I create a reader for this large .car
file?
I think it should be one of these methods, but there's no sample code on how to use it...
import { CarBlockIterator } from '@ipld/car/iterator';
// or
import { CarCIDIterator } from '@ipld/car/iterator';
Upvotes: 0
Views: 212
Reputation: 11957
Figured it out. This works:
import { CarIndexedReader } from '@ipld/car';
const filename = "C:\output.car"
const carReader = await CarIndexedReader.fromFile(filename);
Upvotes: 1