Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ import { MemoryBlockStore } from 'ipfs-car/blockstore/memory' // You can also us
const { root, out } = await pack({
input: [new Uint8Array([21, 31, 41])],
blockstore: new MemoryBlockStore(),
wrapWithDirectory: true // Wraps input into a directory. Defaults to `true`
wrapWithDirectory: false // Wraps inputs with paths into a directory. Defaults to `false`
maxChunkSize: 262144 // The maximum block size in bytes. Defaults to `262144`. Max safe value is < 1048576 (1MiB)
})

Expand All @@ -117,6 +117,21 @@ for await (const part of out) {
}
```

When using `wrapWithDirectory` functionality, a path for the files needs to be provided, in order to have DAG links properly created. See the example as follows:

```js
import { pack } from 'ipfs-car/pack'
import { MemoryBlockStore } from 'ipfs-car/blockstore/memory' // You can also use the `level-blockstore` module

const { root, out } = await pack({
input: [{
path: 'file.txt',
content: new Uint8Array([21, 31, 41])
}],
wrapWithDirectory: true
})
```

### `ipfs-car/pack/blob`

Takes an [ImportCandidateStream](https://github.com/ipfs/js-ipfs/blob/master/packages/ipfs-core-types/src/utils.d.ts#L27) and writes it to a [Blob](https://github.com/web-std/io/tree/main/blob).
Expand Down
Loading