readAsBytes method

  1. @override
Future<Uint8List> readAsBytes()
override

Reads the entire file contents as a list of bytes.

Returns a Future<Uint8List> that completes with the list of bytes that is the contents of the file.

Implementation

@override
Future<Uint8List> readAsBytes() async {
  client.log('WebDAV: GET $path');
  try {
    final resolved = await client.resolvePath(path);
    if (resolved['type'] != 'file') {
      throw io.FileSystemException('Path is not a file', path);
    }

    final result = await client.downloadFile(resolved['uuid']);
    return result['data'] as Uint8List;
  } catch (e) {
    client.log('WebDAV: Error reading $path: $e');
    throw io.FileSystemException('Error reading file', path);
  }
}