Releases: ballerina-platform/module-ballerina-ftp
Ballerina FTP module 0.4.3 released
This module can import via Ballerina central.
Ballerina FTP Module 0.99.2 Released!
This is the compatible connector version of Ballerina v0.991.0
Ballerina FTP Module 0.99.1 Released!
This is the compatible connector version of Ballerina v0.990.3
Ballerina FTP Module 0.99.0 Released!
This is the latest release that compatible with Ballerina runtime 0.990.0.
FTP functionalities haven't changed this release, but syntax changed to compatible with new Ballerina runtime.
FTP Listener
The FTP Listener can be used to listen to a remote directory. It will keep listening to the specified directory and periodically notify the file addition and deletion.
import wso2/ftp;
import ballerina/log;
listener ftp:Listener remoteServer = new({
protocol:ftp:FTP,
host:"localhost",
port:48123,
secureSocket: {
basicAuth: {
username: "ballerina",
password: "ballerina123"
}
},
path:"/home/ballerina"
});
service monitor on remoteLocation {
resource function fileResource (ftp:WatchEvent m) {
foreach ftp:FileInfo v1 in m.addedFiles {
log:printInfo("Added file path: " + v1.path);
}
foreach string v2 in m.deletedFiles {
log:printInfo("Deleted file path: " + v2);
}
}
}
FTP Client
The FTP Client Connector can be used to connect to an FTP server and perform I/O operations.
import wso2/ftp;
import ballerina/io;
function main (string... args) {
ftp:Client ftpClient = new({ protocol: ftp:FTP, host: "127.0.0.1", port: 21 });
// To create a folder in remote server
var dirCreErr = ftpClient -> mkdir("/ballerina-user/sample-dir");
if (dirCreErr is error) {
io:println("An error occured.");
return;
}
}
Ballerina FTP Module 0.98.0 Released!
This is the latest Ballerina FTP Module that compatible with Ballerina version 0.983.0.
Ballerina FTP Package 0.97.5Released!
This is the latest FTP connector which supports for Ballerina runtime V0.982.0.
Ballerina FTP Package 0.97.4 Released!
This is the latest FTP connector which supports for Ballerina runtime V0.981.0. This release improved internal error logging.
Ballerina FTP Package 0.97.3 Released!
We are pleased to announce release of Balleria FTP Package.
This package contains FTP directory listener and an FTP client. Please refer attached api-docs.zip for more information. Please use install.<sh|bat> for install for the Ballerina distribution.
This version support with Ballerina 0.980.0 release only.
Ballerina File Connector 0.97.0 Released!
FTP Listener
The FTP Listener can be used to listen to a remote directory. It will keep listening to the specified directory and periodically notify the file addition and deletion.
import wso2/ftp;
import ballerina/io;
endpoint ftp:Listener remoteLocation {
protocol:ftp:FTP,
host:"localhost",
port:48123,
secureSocket: {
basicAuth: {
username: "ballerina",
password: "ballerina123"
}
},
path:"/home/ballerina"
};
service monitor bind remoteLocation {
fileResource (ftp:WatchEvent m) {
foreach v in m.addedFiles {
io:println("Added file path: ", v.path);
}
foreach v in m.deletedFiles {
io:println("Deleted file path: ", v);
}
}
}
FTP Client
The FTP Client Connector can be used to connect to an FTP server and perform I/O operations.
import wso2/ftp;
import ballerina/io;
endpoint ftp:Client client {
protocol: ftp:FTP,
host:"127.0.0.1",
port:21
};
function main (string[] args) {
// To create a folder in remote server
errorr? dirCreErr = client -> mkdir("/ballerina-user/sample-dir");
match dirCreErr {
error err => {
io:println("An error occured.");
return;
}
() => {}
}
// Upload file to a remote server
io:ByteChannel summaryChannel = io:openFile("/home/ballerina/prog/summary.bal", io:MODE_R);
error? filePutErr = client -> put("/ballerina-user/sample-dir/summary.bal", summaryChannel);
match filePutErr {
error err => {
io:println("An error occured.");
return;
}
() => {}
}
// Get the content list of a given path
var listResult = client -> list("/ballerina-user/sample-dir");
match listResult {
string[] list => {
foreach file in list {
io:println("File: " + file);
}
}
error err=> {
io:println("An error occured.");
return;
}
}
// Get the size of a remote file
int size = check client -> size("/ballerina-user/sample-dir/stock.json");
// Read content of a remote file
var getResult = client -> get("/ballerina-user/sample-dir/stock.json");
match getResult {
io:ByteChannel channel => {
io:CharacterChannel characters = check io:createCharacterChannel(channel, "UTF-8");
json stock = check characters.readJson();
_ = channel.close();
}
error err => {
io:println("An error occured.");
return;
}
}
// Rename or move remote file to a another remote location in a same FTP server
error? renameErr = client -> rename("/ballerina-user/sample-dir/stock.json", "/ballerina-user/sample-dir/done/stock.json");
// Delete remote file
error? fileDelCreErr = client -> delete("/ballerina-user/sample-dir/temp/MyMockProxy.xml");
// Remove direcotry from remote server
_ = client -> rmdir("/ballerina-user/sample-dir/temp");
}
Ballerina File Connector 0.96.0 Released!
Changed the FTPClientConnector read method to return io:ByteChannel.
Introduced new pipe methods to FTPClientConnector to pass through the content.