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][ftp:ClientEndpointConfig]The list() method need to return more clear output #752

Open
isuruuy429 opened this issue Jan 12, 2020 · 0 comments

Comments

@isuruuy429
Copy link
Contributor

Description:
The ftp:ClientEndpointConfig returns an output as below. Assume we have a text file.

2020-01-12 22:17:50,616 INFO [isuruuyanage/basics] - extension=txt isFile=true scheme=ftp rootURI=ftp://ftp-user:ftp-user@192.168.108.65/ isWritable=true uri=ftp://ftp-user:ftp-user@192.168.108.65/home/ftp-user/in/dmajor1.txt lastModifiedTimestamp=0 isHidden=false publicURIString=ftp://ftp-user:***@192.168.108.65/home/ftp-user/in/dmajor1.txt path=/home/ftp-user/in/dmajor1.txt isFolder=false depth=5 size=0 pathDecoded=/home/ftp-user/in/dmajor1.txt name=dmajor1.txt isContentOpen=false friendlyURI=ftp://ftp-user:***@192.168.108.65/home/ftp-user/in/dmajor1.txt isAttached=true isExecutable=false isReadable=true fileType=file/n

We need to simply list down the files and the above provides a lengthy output. Better if we have a way to filter the file/directory names.

The resource is implemented as below.

@http:ResourceConfig {
        path: "/listFiles/{customizedLocation}"
    }

    resource function listFiles(http:Caller caller, http:Request request, string customizedLocation)returns error?{
        http:Response response = new ();
        var ftpResult = ftp->list(customizedLocation);

        if (ftpResult is error) {
            response.setJsonPayload({Message: "Error occurred while listing the files", Reason: ftpResult.reason()});
            log:printError("Error occurred while listing the files", ftpResult);
        }
        else
        {

            response.setJsonPayload({Files: ftpResult.toString()});
        }
        var httpResult = caller->respond(response);

    }

Further, in ftp connector tests[1], we have FileInfo[] as a type which now says it's an unknown type. Therefore it needs to be addressed as well.

[1] - https://github.com/wso2-ballerina/module-ftp/blob/master/ftp/src/ftp/tests/client_endpoint_test.bal

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