openRead method

  1. @override
Stream<List<int>> openRead([
  1. int? start,
  2. int? end
])
override

Creates a new independent Stream for the contents of this file starting from start and ending at end.

Throws InvalidFileException if the AWSFile is initiated using AWSFile.fromStream.

Implementation

@override
Stream<List<int>> openRead([int? start, int? end]) {
  final file = _inputFile ?? _inputBlob;
  if (file != null) {
    return _getReadStream(file, start: start, end: end);
  }

  final inputBytes = super.bytes;
  if (inputBytes != null) {
    return Stream.value(inputBytes.sublist(start ?? 0, end));
  }

  final path = super.path;
  if (path != null) {
    return _getReadStream(_resolvedBlob, start: start, end: end);
  }

  throw const InvalidFileException(
    recoverySuggestion:
        'Cannot use `openRead` with an AWSFile that is initiated with a stream.',
  );
}