| | |
| | | package org.dromara.system.uitil; |
| | | |
| | | import cn.hutool.extra.ftp.Ftp; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.commons.net.ftp.FTP; |
| | | import org.apache.commons.net.ftp.FTPClient; |
| | |
| | | /** |
| | | * 实现FTP文件上传和文件下载 |
| | | */ |
| | | @Slf4j |
| | | public class FtpApche { |
| | | private static FTPClient ftpClient = new FTPClient(); |
| | | private static String encoding = System.getProperty("file.encoding"); |
| | |
| | | InputStream input = file.getInputStream(); |
| | | try { |
| | | connect(config); |
| | | ftpClient.setBufferSize(1024 * 1024); |
| | | // 设置缓冲区5M |
| | | ftpClient.setBufferSize(1024 * 1024 * 5); |
| | | result = ftpClient.storeFile(new String(name.getBytes(encoding), "iso-8859-1"), input); |
| | | if (result) { |
| | | System.out.println("上传成功!"); |
| | | log.error("上传成功!"); |
| | | } |
| | | input.close(); |
| | | } catch (IOException e) { |