solve the issue that ftpwriter is unable to write file to root path e.g. /test.txt

This commit is contained in:
zc 2021-02-05 15:40:50 +08:00
parent 33e6ace661
commit 132a37475a
2 changed files with 2 additions and 4 deletions

View File

@ -195,8 +195,7 @@ public class SftpHelperImpl implements IFtpHelper {
public OutputStream getOutputStream(String filePath) {
try {
this.printWorkingDirectory();
String parentDir = filePath.substring(0,
StringUtils.lastIndexOf(filePath, IOUtils.DIR_SEPARATOR));
String parentDir = FilenameUtils.getFullPathNoEndSeparator(filePath);
this.channelSftp.cd(parentDir);
this.printWorkingDirectory();
OutputStream writeOutputStream = this.channelSftp.put(filePath,

View File

@ -181,8 +181,7 @@ public class StandardFtpHelperImpl implements IFtpHelper {
public OutputStream getOutputStream(String filePath) {
try {
this.printWorkingDirectory();
String parentDir = filePath.substring(0,
StringUtils.lastIndexOf(filePath, IOUtils.DIR_SEPARATOR));
String parentDir = FilenameUtils.getFullPathNoEndSeparator(filePath);
this.ftpClient.changeWorkingDirectory(parentDir);
this.printWorkingDirectory();
OutputStream writeOutputStream = this.ftpClient