Skip to content

Commit

Permalink
Merge pull request #5271 from ballerina-platform/update-ftp
Browse files Browse the repository at this point in the history
[master] Update ftp file api used in the BBEs
  • Loading branch information
dilanSachi authored Mar 27, 2024
2 parents c37c200 + 399d273 commit 976a3c2
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ service on fileListener {
// after the last polling was called.
foreach ftp:FileInfo addedFile in event.addedFiles {
// Get the newly added file from the FTP server as a `byte[]` stream.
stream<byte[] & readonly, io:Error?> fileStream = check caller->get(addedFile.path);
stream<byte[] & readonly, io:Error?> fileStream = check caller->get(addedFile.pathDecoded);

// Write the content to a file.
check io:fileWriteBlocksFromStream(string `./local/${addedFile.name}`, fileStream);
Expand Down
2 changes: 1 addition & 1 deletion examples/ftp-service-send-file/ftp_service_send_file.bal
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ service on fileListener {
foreach ftp:FileInfo addedFile in event.addedFiles {
// The `ftp:Caller` can be used to append another file to the added files in the server.
stream<io:Block, io:Error?> fileStream = check io:fileReadBlocksAsStream("./local/appendFile.txt", 7);
check caller->append(addedFile.path, fileStream);
check caller->append(addedFile.pathDecoded, fileStream);
check fileStream.close();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ service on fileListener {
// after the last polling was called.
foreach ftp:FileInfo addedFile in event.addedFiles {
// Get the newly added file from the SFTP server as a `byte[]` stream.
stream<byte[] & readonly, io:Error?> fileStream = check caller->get(addedFile.path);
stream<byte[] & readonly, io:Error?> fileStream = check caller->get(addedFile.pathDecoded);

// Write the content to a file.
check io:fileWriteBlocksFromStream(string `./local/${addedFile.name}`, fileStream);
Expand Down
2 changes: 1 addition & 1 deletion examples/sftp-service-send-file/sftp_service_send_file.bal
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ service on fileListener {
foreach ftp:FileInfo addedFile in event.addedFiles {
// The `ftp:Caller` can be used to append another file to the added files in the server.
stream<io:Block, io:Error?> fileStream = check io:fileReadBlocksAsStream("./local/appendFile.txt", 7);
check caller->append(addedFile.path, fileStream);
check caller->append(addedFile.pathDecoded, fileStream);
check fileStream.close();
}
}
Expand Down

0 comments on commit 976a3c2

Please sign in to comment.