public Stream<ResourceDescriptor> listPrivateFilesFromFolderWithSubFolders(ResourceDescriptor folderDescriptor) {
        if (!folderDescriptor.isFolder()) {
            return Stream.empty();
        }

        List<ResourceDescriptor> fileDescriptors = new ArrayList<>();
        String nextToken = null;

        do {
            try {
                ResourceFolderMetadata folderMetadata =
                        resourceService.getFolderMetadata(folderDescriptor, nextToken, 1000, true);

                if (folderMetadata == null || folderMetadata.getItems() == null) {
                    break;
                }

                // Process all files in this page
                folderMetadata.getItems().stream()
                        .filter(item -> item.getNodeType() != NodeType.FOLDER)
                        .map(item -> ResourceDescriptorFactory.fromPrivateUrl(item.getUrl(), encryption))
                        .forEach(fileDescriptors::add);

                nextToken = folderMetadata.getNextToken();
            } catch (Exception e) {
                log.warn("Failed to list files in folder while publishing: {}", folderDescriptor.getUrl(), e);
                throw new RuntimeException(e);
            }
        } while (nextToken != null);

        return fileDescriptors.stream();
    }
Leaves only required fields for listing.
server/src/main/java/com/epam/aidial/core/server/service/PublicationService.java