Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add data binding support for FTP client #4234

Open
dilanSachi opened this issue Mar 21, 2023 · 1 comment
Open

Add data binding support for FTP client #4234

dilanSachi opened this issue Mar 21, 2023 · 1 comment
Assignees
Labels
module/ftp Team/PCM Protocol connector packages related issues Type/Task

Comments

@dilanSachi
Copy link
Contributor

Description:
At the moment, when we need to read a remote file content, we have to something like below.

service on remoteServer {
    remote function onFileChange(ftp:WatchEvent & readonly fileEvent, ftp:Caller caller)  {
        foreach ftp:FileInfo addedFile in fileEvent.addedFiles {
            stream<byte[] & readonly, io:Error?> fileStream = check caller->get(addedFile.path);
            json|error j = fromBytesToJson(fileStream);
            io:println(j);
        }
    }
}

function fromBytesToJson(stream<byte[] & readonly, io:Error?> fileStream) returns json|error {
    byte[] bytes = [];
    check fileStream.forEach(function(byte[] & readonly block) {
        bytes.push(...block);
    });
    string s = check string:fromBytes(bytes);
    json j = check s.fromJsonString();
    return j;
}

Rather than this, its better to have something as follows.

json jsonContent = check caller->get(addedFile.path);
csv csvContent = check caller->get(addedFile.path);
xml xmlContent = check caller->get(addedFile.path);
byte[] byteContent = check caller->get(addedFile.path);
@dilanSachi dilanSachi added Type/Task module/ftp Team/PCM Protocol connector packages related issues labels Mar 21, 2023
@dilanSachi
Copy link
Contributor Author

We can also support a list of a record types etc.

Person[] person = check caller->get(addedFile.path);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module/ftp Team/PCM Protocol connector packages related issues Type/Task
Projects
Status: In Progress
Development

No branches or pull requests

2 participants