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

[FTP Connector]It only outputs the file size when getting the file size but not the unit. #737

Open
isuruuy429 opened this issue Dec 17, 2019 · 0 comments

Comments

@isuruuy429
Copy link
Contributor

isuruuy429 commented Dec 17, 2019

Description:
$subject.

Steps to Reproduce

  1. Create a new Ballerina Project.
  2. Connect to the FTP server and upload employees.xml file to the /home/ftp-user/in location.
  3. Have the following code.
import wso2/ftp;
import ballerina/config;
import ballerina/http;
import ballerina/log;

ftp:ClientEndpointConfig ftpConfig = {
    protocol: ftp:FTP,
    host: config:getAsString("ftp.host"),
    port: config:getAsInt("ftp.port"),
    secureSocket: {
        basicAuth: {
            username: config:getAsString("ftp.username"),
            password: config:getAsString("ftp.password")
        }
    }
};
ftp:Client ftp = new(ftpConfig);

@http:ServiceConfig {
    basePath: "company"
}

 resource function retreiveFileSize(http:Caller caller, http:Request request) returns error? {
        http:Response response = new();
        var sizeResponse = ftp->size("/home/ftp-user/in/employees.xml");
        if (sizeResponse is int) {
            response.setJsonPayload("File size: " +sizeResponse.toString());
            log:printInfo("File size: " + sizeResponse.toString());
    } else {
        response.setJsonPayload({Message: "Error occured in retrieving size", Reason: sizeResponse.reason()});
        log:printError("Error occured in retrieving size", sizeResponse);
    }
    var httpResult = caller->respond(response); 

    }
}
  1. Build the module, run the jar and invoke the service.
    curl http://localhost:9090/company/retreiveFileSize

It only outputs the size of the file, but not the unit.

Affected Product Version:
Ballerina Integrator 7.0.1
Ballerina version: 1.0.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant