feat(example):add MFS-based UnixFS to CAR example #1056
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #663
Summary
Adds a example demonstrating how to create UnixFS DAGs and export them as CAR files using MFS (Mutable File System)
What's Included
✅ Proper Chunking (Not
io.ReadAll)--chunker size-[bytes]--chunker rabin-[min]-[avg]-[max](content-defined)--chunker buzhash✅ Directory Support
✅ HAMT Sharding
--max-directory-links✅ All Major
ipfs addFlags--chunker,--raw-leaves--cid-version,--hash,--inline,--inline-limit--trickle(trickle DAG)--preserve-mode,--preserve-mtime✅ MFS Integration
mfs.NewRoot()to create filesystemmfs.PutNode()for adding nodesroot.Flush()to persist changesExample Usage
Basic File
Output:
Directory
With All Flags
Testing
All 13 tests pass:
$ go test -v === RUN TestBasicFileConversion --- PASS: TestBasicFileConversion (0.00s) === RUN TestLargeFileWithChunking --- PASS: TestLargeFileWithChunking (0.01s) === RUN TestDirectoryConversion --- PASS: TestDirectoryConversion (0.00s) === RUN TestRawLeaves --- PASS: TestRawLeaves (0.00s) === RUN TestTrickleDAG --- PASS: TestTrickleDAG (0.00s) === RUN TestMetadataPreservation --- PASS: TestMetadataPreservation (0.00s) === RUN TestDifferentHashFunctions --- PASS: TestDifferentHashFunctions (0.00s) === RUN TestDifferentChunkers --- PASS: TestDifferentChunkers (0.01s) === RUN TestInvalidHashFunction --- PASS: TestInvalidHashFunction (0.00s) === RUN TestInvalidChunker --- PASS: TestInvalidChunker (0.00s) === RUN TestNonExistentFile --- PASS: TestNonExistentFile (0.00s) === RUN TestLargeDirectoryWithHAMT --- PASS: TestLargeDirectoryWithHAMT (0.03s) PASS ok github.com/ipfs/boxo/examples/unixfs-to-car 0.287sTests cover:
Implementation Details
MFS-Based Workflow
This follows the same pattern as Kubo's
ipfs add --to-files(seekubo/core/commands/add.go).Screenrecording
Screen.Recording.2025-10-20.at.11.39.03.AM.mp4
Documentation
README includes:
ipfs add@lidel this implementation satisfies all listed requirements and is ready for review!