资源库:SFTP上传下载删除功能优化,根据yml中配置uploadType来实现本地还是sftp上传
This commit is contained in:
parent
61a8fc5198
commit
f7b644ecae
|
@ -166,7 +166,7 @@ public class SFTPUtil {
|
||||||
try{
|
try{
|
||||||
sftp = connect(sftpConfig);
|
sftp = connect(sftpConfig);
|
||||||
try {
|
try {
|
||||||
directory = getDirectory(sftpConfig.getUploadpath(), directory);
|
// directory = getDirectory(sftpConfig.getUploadpath(), directory);
|
||||||
sftp.cd(directory);
|
sftp.cd(directory);
|
||||||
} catch (SftpException e1) {
|
} catch (SftpException e1) {
|
||||||
try {
|
try {
|
||||||
|
@ -386,14 +386,13 @@ public class SFTPUtil {
|
||||||
map.put("msg", "ftp创建" + directory + "文件路径失败");
|
map.put("msg", "ftp创建" + directory + "文件路径失败");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Session session = null;
|
|
||||||
Channel channel = null;
|
Channel channel = null;
|
||||||
try {
|
try {
|
||||||
String oldfullpath = sftpConfig.getFullpath().concat(oldpath);
|
String oldfullpath = sftpConfig.getFullpath().concat(oldpath);
|
||||||
String newpath = directory.concat(newname);
|
String newpath = directory.concat(newname);
|
||||||
String newfullpath = sftpConfig.getFullpath().concat(newpath);
|
String newfullpath = sftpConfig.getFullpath().concat(newpath);
|
||||||
String moveCommand = "mv " + oldfullpath + " " + newfullpath; // 移动文件的命令
|
String moveCommand = "mv " + oldfullpath + " " + newfullpath; // 移动文件的命令
|
||||||
session = sftp.getSession();
|
Session session = sftp.getSession();
|
||||||
channel = session.openChannel("exec");
|
channel = session.openChannel("exec");
|
||||||
((ChannelExec) channel).setCommand(moveCommand);
|
((ChannelExec) channel).setCommand(moveCommand);
|
||||||
channel.setInputStream(null);
|
channel.setInputStream(null);
|
||||||
|
|
Loading…
Reference in New Issue