I'm using 'wso2/ftp' package for some file transferring process and have an ftp:Client endpoint as follows in my main .bal file.
endpoint ftp:Client server1 {
protocol: ftp:FTP,
host:<ip_address>,
port:21,
secureSocket: {
basicAuth: {
username: <user_name>,
password: <password>
}
}
};
What are the ways to pass this endpoint to a public function in another .bal file.
Tried to do as,
function functionName(ftp:Client server1){
functionFromOtherBalFile(server1);
}
but get an error as
invalid action invocation, expected an endpoint
from the second .bal file which contains the 'functionFromOtherBalFile' implementation.
Implementation of the 'functionFromOtherBalFile':
public function functionFromOtherBalFile(ftp:Client server1){
var readFile=server1->get("/file.txt");
match readFile{
error err=>{
io:println("An error occured");
return err;
}
io:ByteChannel =>{
io:println("Success");
return readFile;
}
}
}
Could someone please help me to solve this issue.