简体   繁体   中英

Spring-boot restful web service connect to ftp server

Firstly , I am really new to spring framework and java.

I have the following, FTP server with subdirectory containing files.

I want to make getAll / getOne request to the server and also a process method where I will do asynchronous processing of a file and save it to a new subdirectory and notify client once processing complete.

So far I have managed to make GET / POST / DELETE requests to hard coded entities and display this in browser, also got similar functionality using embedded derby server. Have model with constructor, getters and setters, created mappings to URI in my controller which calls my services to complete the request.

I'm struggling to figure out where do I implement the code to actually connect to the ftp server and how i do the processing asynchronously on the server itself.

Any link to resources or pseudo code to help me understand would be amazing, spring docs are quite complicated for my level. I couldn't find any simple(ish) examples to help me understand.

Thanks

Create a FtpService class and annotate it with @Service. create a connect method inside it.

in the main method use the ftp service to connect to the ftp

FtpService ftpService = context.getBean(FtpService.class);
ftpService.connect();

you can read about the @Async annotation that can make the process of the recieved files work asynchronously

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