getDocumentStream method

Future<Uint8List?> getDocumentStream(
  1. String host,
  2. String docId
)

Get document content as byte stream.

host - The host server URL. docId - The ID of the document.

Returns a Uint8List containing the byte stream of the document content.

Implementation

Future<Uint8List?> getDocumentStream(String host, String docId) async {
  final url = '$host/api/storage/documents/$docId/content';

  try {
    final response = await http.get(Uri.parse(url));
    if (response.statusCode == 200) {
      return response.bodyBytes;
    }
  } catch (error) {}

  return null;
}