Summary
Add Stream-based overloads for create, verify, and extract operations to avoid loading entire files into byte[], enabling support for large files with lower memory pressure.
Problem
Current API requires byte[] for all operations. For large files (hundreds of MB or more), this causes unnecessary memory allocations and prevents streaming scenarios. The CreateAsync(Stream, ...) overload exists but internally copies to byte[].
Proposed Solution
Create
CreateAsync(Stream data, string fileName, Stream output, CancellationToken) — write the container directly to an output stream without materializing the full container in memory
- Hash the input stream incrementally instead of buffering
Verify
VerifyAsync(Stream containerStream) — read and verify from a stream without loading the full container into byte[]
- Note:
ZipArchive already accepts streams, so this is mostly API surface
Extract
ExtractAsync(Stream containerStream, Stream output) — extract data file directly to an output stream
CLI
- The CLI already works with file paths, so it benefits automatically from stream-based internals
Considerations
ZipArchive requires a seekable stream for read mode — may need to document this limitation or buffer selectively
- Hashing can be done incrementally via
IncrementalHash or CryptoStream
- Backward compatible — existing
byte[] overloads remain, new stream overloads are additive
Summary
Add
Stream-based overloads for create, verify, and extract operations to avoid loading entire files intobyte[], enabling support for large files with lower memory pressure.Problem
Current API requires
byte[]for all operations. For large files (hundreds of MB or more), this causes unnecessary memory allocations and prevents streaming scenarios. TheCreateAsync(Stream, ...)overload exists but internally copies tobyte[].Proposed Solution
Create
CreateAsync(Stream data, string fileName, Stream output, CancellationToken)— write the container directly to an output stream without materializing the full container in memoryVerify
VerifyAsync(Stream containerStream)— read and verify from a stream without loading the full container intobyte[]ZipArchivealready accepts streams, so this is mostly API surfaceExtract
ExtractAsync(Stream containerStream, Stream output)— extract data file directly to an output streamCLI
Considerations
ZipArchiverequires a seekable stream for read mode — may need to document this limitation or buffer selectivelyIncrementalHashorCryptoStreambyte[]overloads remain, new stream overloads are additive