listUserFiles method

Future<ServerResponse> listUserFiles({
  1. required String cloudPath,
  2. bool? recurse,
})

List user files from the given cloud path

@param cloudPathFile path

@param recurseWhether to recurse down the path

returns Future<ServerResponse>

Implementation

Future<ServerResponse> listUserFiles({required String cloudPath, bool? recurse}) async {
  Map<String, dynamic> data = {};

  if (Util.isOptionalParameterValid(cloudPath)) {
    data[OperationParam.uploadPath.value] = cloudPath;
  }

  if (recurse != null) {
    data[OperationParam.uploadRecurse.value] = recurse;
  }

  final Completer<ServerResponse> completer = Completer();
  var callback = BrainCloudClient.createServerCallback((response) {
    ServerResponse responseObject = ServerResponse.fromJson(response);
    completer.complete(responseObject);
  }, (statusCode, reasonCode, statusMessage) {
    completer.complete(ServerResponse(
        statusCode: statusCode,
        reasonCode: reasonCode,
        error: statusMessage));
  });

  ServerCall sc = ServerCall(
      ServiceName.file, ServiceOperation.listUserFiles, data, callback);
  _clientRef.sendRequest(sc);

  return completer.future;
}