fix: FTP上传中文乱码
This commit is contained in:
parent
2c471fd076
commit
b86961c9d4
@ -76,7 +76,13 @@ public class FtpTool {
|
||||
ftpClient.setConnectTimeout(TIMEOUT);
|
||||
ftpClient.connect(HOST, PORT);
|
||||
ftpClient.login(USER_NAME, PWD);
|
||||
//开启服务器对UTF-8的支持,如果服务器支持就用UTF-8编码,否则就用本地编码(ISO-8859-1)
|
||||
if (FTPReply.isPositiveCompletion(ftpClient.sendCommand("OPTS UTF8", "ON"))) {
|
||||
ftpClient.setControlEncoding("UTF-8");
|
||||
} else {
|
||||
//FTP协议里面,规定文件名编码为iso-8859-1
|
||||
ftpClient.setControlEncoding("ISO-8859-1");
|
||||
}
|
||||
ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
|
||||
if (!FTPReply.isPositiveCompletion(ftpClient.getReplyCode())) {
|
||||
log.error("连接FTP失败,用户名或密码错误;用户名:{};密码{}", USER_NAME, PWD);
|
||||
|
Loading…
Reference in New Issue
Block a user