download method

Future<Uint8List> download({
  1. required String projectId,
  2. required String path,
})

Corresponds to: POST /projects/:project_id/storage/download

Implementation

Future<Uint8List> download({required String projectId, required String path}) async {
  final uri = Uri.parse('$baseUrl/projects/$projectId/storage/download').replace(queryParameters: {"path": path});

  final response = await http.get(uri, headers: _getHeaders());

  if (response.statusCode == 404) {
    throw NotFoundException("file was not found");
  }
  if (response.statusCode >= 400) {
    throw MeshagentException(
      'Failed to create share. '
      'Status code: ${response.statusCode}, body: ${response.body}',
    );
  }

  return response.bodyBytes;
}