huanghongfa
2020-12-03 00036b47f300ac0221075aab1e2d366003195289
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
//package com.panzhihua.common.config;
//
//import com.panzhihua.common.constants.FtpConstants;
//import lombok.extern.slf4j.Slf4j;
//import org.apache.commons.net.ftp.FTPClient;
//import org.apache.commons.net.ftp.FTPReply;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//
//import java.io.IOException;
//import java.net.SocketException;
//
///**
// * @program: springcloud_k8s_panzhihuazhihuishequ
// * @description: ftp
// * @author: huang.hongfa weixin hhf9596 qq 959656820
// * @create: 2020-11-30 13:37
// **/
//@Slf4j
//@Configuration
//public class FtpConfig {
//
//    @Bean
//    public FTPClient ftpClient(){
//        FTPClient ftpClient = new FTPClient();
//        ftpClient.setConnectTimeout(1000*30);//设置连接超时时间
//        ftpClient.setControlEncoding("utf-8");//设置ftp字符集
////        ftpClient.enterLocalPassiveMode();//设置被动模式,文件传输端口设置
//        try {
////            ftpClient.setFileType(FTP.BINARY_FILE_TYPE);//设置文件传输模式为二进制,可以保证传输的内容不会被改变
//            ftpClient.setDefaultPort(FtpConstants.FTPPORT);
//            ftpClient.connect(FtpConstants.FTPHOST, FtpConstants.FTPPORT);
//            ftpClient.login(FtpConstants.FTPUSERNAME,FtpConstants.FTPPASSWORD);
//            int replyCode = ftpClient.getReplyCode();
//            if (!FTPReply.isPositiveCompletion(replyCode)){
//                ftpClient.disconnect();
//                log.error("未连接到FTP,用户名或密码错误!");
//                return null;
//            }else {
//                log.error("FTP连接成功!");
//                return ftpClient;
//            }
//        } catch (SocketException socketException) {
//            log.error("FTP的IP地址可能错误,请正确配置!");
//            return null;
//        } catch (IOException ioException) {
//            ioException.printStackTrace();
//            log.error("FTP的端口错误,请正确配置!");
//            return null;
//        }
//    }
//}