feat: FTP调整
This commit is contained in:
parent
bb1e33b8ef
commit
9237e8e4d0
@ -145,23 +145,4 @@ public class CommonController {
|
||||
log.error("下载文件失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* ftp获取单个文件
|
||||
*/
|
||||
@GetMapping("/ftp/**")
|
||||
public void getFtpFile(HttpServletRequest request, HttpServletResponse response) {
|
||||
try {
|
||||
// 下载文件并获取文件流
|
||||
InputStream fileStream = sysFileService.getFtpFile(request.getRequestURI().substring(4));
|
||||
// 设置响应头
|
||||
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
|
||||
// 将文件流输出到响应
|
||||
IOUtils.copy(fileStream, response.getOutputStream());
|
||||
response.flushBuffer();
|
||||
} catch (IOException e) {
|
||||
// 异常处理
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -90,3 +90,14 @@ spring:
|
||||
wall:
|
||||
config:
|
||||
multi-statement-allow: true
|
||||
ftp:
|
||||
# ftp地址
|
||||
host: pnkx.cloud
|
||||
# ftp端口
|
||||
port: 21
|
||||
# ftp用户名
|
||||
username: peihaoyu
|
||||
# ftp密码
|
||||
password: Phy0316.
|
||||
# ftp上传路径
|
||||
path: /
|
||||
|
@ -90,3 +90,14 @@ spring:
|
||||
wall:
|
||||
config:
|
||||
multi-statement-allow: true
|
||||
ftp:
|
||||
# ftp地址
|
||||
host: 192.168.31.104
|
||||
# ftp端口
|
||||
port: 21
|
||||
# ftp用户名
|
||||
username: peihaoyu
|
||||
# ftp密码
|
||||
password: Phy0316.
|
||||
# ftp上传路径
|
||||
path: /
|
||||
|
@ -90,3 +90,14 @@ spring:
|
||||
wall:
|
||||
config:
|
||||
multi-statement-allow: true
|
||||
ftp:
|
||||
# ftp地址
|
||||
host: pnkx.cloud
|
||||
# ftp端口
|
||||
port: 21
|
||||
# ftp用户名
|
||||
username: peihaoyu
|
||||
# ftp密码
|
||||
password: Phy0316.
|
||||
# ftp上传路径
|
||||
path: /
|
||||
|
@ -41,7 +41,7 @@ spring:
|
||||
# 国际化资源文件路径
|
||||
basename: i18n/messages
|
||||
profiles:
|
||||
active: nas
|
||||
active: dev
|
||||
# 文件上传
|
||||
servlet:
|
||||
multipart:
|
||||
|
@ -14,5 +14,5 @@ public class WebsiteAddressConstants {
|
||||
public static final String WEB_SITE_ADDRESS = "https://pnkx.top/";
|
||||
|
||||
// FTP服务器地址
|
||||
public static final String FTP_SITE_ADDRESS = "https://pnkx.cloud:8866/";
|
||||
public static final String FTP_SITE_ADDRESS = "https://ftp.pnkx.top:8";
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import org.apache.commons.net.ftp.FTPFile;
|
||||
import org.apache.commons.net.ftp.FTPReply;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@ -21,8 +22,6 @@ import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static cn.hutool.db.DbUtil.close;
|
||||
|
||||
/**
|
||||
* FtpConfig
|
||||
*
|
||||
@ -44,23 +43,28 @@ public class FtpTool {
|
||||
/**
|
||||
* ftp 服务地址
|
||||
*/
|
||||
private static final String HOST = "pnkx.cloud";
|
||||
@Value("${ftp.host}")
|
||||
private String HOST;
|
||||
/**
|
||||
* ftp 服务账户
|
||||
*/
|
||||
private static final String USER_NAME = "peihaoyu";
|
||||
@Value("${ftp.username}")
|
||||
private String USER_NAME;
|
||||
/**
|
||||
* ftp 密码
|
||||
*/
|
||||
private static final String PWD = "Phy0316.";
|
||||
@Value("${ftp.password}")
|
||||
private String PWD;
|
||||
/**
|
||||
* 端口 ftp 默认 21 ,登录端口。20为传输端口,此处使用连接端口
|
||||
*/
|
||||
private static final Integer PORT = 21;
|
||||
@Value("${ftp.port}")
|
||||
private Integer PORT;
|
||||
/**
|
||||
* 目录
|
||||
*/
|
||||
private static final String PATH = "/";
|
||||
@Value("${ftp.path}")
|
||||
private String PATH;
|
||||
|
||||
/**
|
||||
* 创建连接
|
||||
|
Loading…
Reference in New Issue
Block a user