getAllFiles method

Future<List> getAllFiles({
  1. String? folderPath,
})

Implementation

Future<List<dynamic>> getAllFiles({String? folderPath}) async {
  try {
    final url = Uri.parse('$apiHost/v1/filehandling/listFiles')
        .replace(queryParameters: {
      'org_name': Constants.orgId,
      'workspace_name': Constants.workspaceId,
      if (folderPath != null) 'folder_name': folderPath,
    });
    print('URL----$url');

    final response = await http.get(url, headers: {
      'content-type': 'application/json',
    });
    if (response.statusCode == 200) {
      final List<dynamic> files = json.decode(response.body);
      print('All files ${files}');
      return files;
    } else {
      throw Exception('Failed to retrieve files. Error: ${response.statusCode}');
    }
  } catch (e) {
    print('Error: $e');
    return [];
  }
}