Skip to content

feat: stream-based overloads to avoid byte[] allocations #4

@stevehansen

Description

@stevehansen

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions