|
|
@@ -9,6 +9,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import java.io.InputStream;
|
|
|
+import java.util.Properties;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
|
@@ -51,7 +52,9 @@ public class WelcomeFileController implements WelcomeFileControllerAPI {
|
|
|
try {
|
|
|
session = jsch.getSession(user, host, port);
|
|
|
session.setPassword(password);
|
|
|
- session.setConfig("StrictHostKeyChecking", "no");
|
|
|
+ Properties config = new Properties();
|
|
|
+ config.put("StrictHostKeyChecking", "no");
|
|
|
+ session.setConfig(config);
|
|
|
session.connect(30000);
|
|
|
System.out.println("连接成功");
|
|
|
channelSftp = (ChannelSftp) session.openChannel("sftp");
|
|
|
@@ -72,6 +75,7 @@ public class WelcomeFileController implements WelcomeFileControllerAPI {
|
|
|
channelSftp.put(inputStream, name);
|
|
|
// 从远程服务器上下载文件
|
|
|
//channelSftp.get(downpath, spath);
|
|
|
+ result.setUrl("https://chtech.ncjti.edu.cn/welcome/homeimage/" + name);
|
|
|
} catch (JSchException e) {
|
|
|
e.printStackTrace();
|
|
|
} finally {
|
|
|
@@ -81,7 +85,9 @@ public class WelcomeFileController implements WelcomeFileControllerAPI {
|
|
|
if (session != null) {
|
|
|
session.disconnect();
|
|
|
}
|
|
|
- result.setUrl("https://chtech.ncjti.edu.cn/welcome/homeimage/" + name);
|
|
|
+ }
|
|
|
+ if(!org.springframework.util.StringUtils.hasText(result.getUrl())){
|
|
|
+ return CommonResult.fail("图片上传失败");
|
|
|
}
|
|
|
return CommonResult.ok(result);
|
|
|
}
|