getTables method

Future<List<String?>> getTables()

Get a list of all tables in storage accout

Implementation

Future<List<String?>> getTables() async {
  String path = 'https://${config[accountName]}.table.core.windows.net/Tables';
  var request = http.Request('GET', Uri.parse(path));
  request.headers['Accept'] = 'application/json;odata=nometadata';
  request.headers['Content-Type'] = 'application/json';
  _sign4Tables(request);

  var res = await request.send();
  var message = await res.stream.bytesToString();

  if (res.statusCode == 200) {
    List<String?> tabList = [];
    var jsonResponse = await jsonDecode(message);
    for (var tData in jsonResponse['value']) {
      tabList.add(tData['TableName']);
    }
    return tabList;
  }
  throw AzureStorageException(message, res.statusCode, res.headers);
}