简体   繁体   中英

How to connect MFT server with rest exposed to perform operations like upload, download and list files using java + spring code Implementation

My goal is to establish connection from an MFT server using (spring+java) implementation to perform basic operation like listing, uploading and deleting files and i'm stuck at a point where i'm not even able to establish any connection from server. The MFT team has exposed their services via REST (ie, HTTPS protocol).

My code that i have tried and which is failing is

        FTPClient ftp = new FTPClient();
        ftp.addProtocolCommandListener(new PrintCommandListener(new PrintWriter(System.out)));
        ftp.connect(host, port);

        Integer reply = ftp.getReplyCode();
        if (!FTPReply.isPositiveCompletion(reply)) 
        {
            ftp.disconnect();
            throw new IOException("Exception in connecting to FTP Server");
        }

        ftp.login(user, password);

        return ftp;

I'm getting error stating UNKNOWNHOSTEXCEPTION. I'm guessing the probable cause is that server is exposing http service while i'm trying to use FTPClient, I'm not sure which library to use and how to proceed next.

There are basic libraries by java like java.net.URL which may help but they do not support listing of files. Please suggest any library which may help me out or some relevant reference or any resource.

I used httpclient library provided by apache and it worked very nicely. it's a good library and provide support for get, put, post and other request types.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM