byteStream method

Stream<Uint8List> byteStream({
  1. int offset = 1,
  2. int? pieceSize,
})

Streams this BLOB's bytes from 1-based offset to the end of the LOB in pieces of at most pieceSize bytes, one TTC LOB READ round trip per piece.

The CLOB/NCLOB sibling is textStream; every contract described there applies here with bytes as the unit (BLOB offsets, amounts and length are byte counts), minus the character-boundary caveat — raw bytes have none: the concatenation of the emitted pieces equals read(offset: offset) byte for byte for a LOB whose length has not changed since it was fetched (a LOB that grew server-side afterwards streams strictly more than read's stale-length prefix — same trade-off as textStream), pieceSize defaults to chunkSize (or defaultLobStreamPieceSize when unknown), the stream ends on an empty server READ, liveness is re-checked per piece, and cancelling leaves the connection immediately reusable.

The element type deliberately narrows to Uint8List (a subtype of Stream<List<int>>) — it is what the READ path already produces, and it spares every subscriber a cast.

Throws synchronously: StateError if this handle is a CLOB/NCLOB (use textStream), ArgumentError for a non-positive offset / pieceSize, and OracleException for a closed handle or a closed/broken connection.

Implementation

Stream<Uint8List> byteStream({int offset = 1, int? pieceSize}) {
  _ensureOpen();
  if (!_isBlob) {
    throw StateError(
      'byteStream() is only available on a BLOB OracleLob; this handle is a '
      '${type == OracleDbType.nClob ? 'NCLOB' : 'CLOB'} — use textStream() '
      'instead.',
    );
  }
  final units = _validateStreamArgs(offset, pieceSize);
  return _bytePieces(offset, units);
}