readLargeFileAsBytes function

Future<Uint8List> readLargeFileAsBytes({
  1. required String remoteFilePath,
  2. String? ownerWebId,
  3. bool isPodRelativePath = false,
  4. void onProgress(
    1. int,
    2. int
    )?,
})

Get a large file previously sent using writeLargeFile with name remoteFilePath (relative to appname/data directory) and return it as bytes.

Implementation

Future<Uint8List> readLargeFileAsBytes({
  required String remoteFilePath,
  String? ownerWebId,
  bool isPodRelativePath = false,
  void Function(int, int)? onProgress,
}) async {
  final chunks = fetch(
    remoteFilePath: remoteFilePath,
    ownerWebId: ownerWebId,
    isPodRelativePath: isPodRelativePath,
    onProgress: onProgress,
  );
  final builder = BytesBuilder();

  await for (final chunk in chunks) {
    builder.add(chunk);
  }

  return builder.toBytes();
}