This commit is contained in:
hky 2023-10-12 16:18:15 +08:00
parent 3e401eafad
commit 94090bfcb8

View File

@ -0,0 +1,43 @@
package org.jeecg.modules.project.baseAPI.sftpAPI.impl;
import org.jeecg.modules.project.baseAPI.sftpAPI.IBizSftpAPIService;
import org.jeecg.modules.project.baseAPI.sftpAPI.SFTPUtil;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.io.FileInputStream;
import java.io.InputStream;
/**
* @Description: 通用API
* @Author: jeecg-boot
* @Date: 2023-09-20
* @Version: V1.0
*/
@Service
public class BizSftpAPIServiceImpl implements IBizSftpAPIService {
@Value("${spring.Linux.ip}")
private String ip;
@Value("${spring.Linux.username}")
private String username;
@Value("${spring.Linux.password}")
private String password;
@Value("${spring.Linux.port}")
private Integer port;
@Override
public void sftpUpload(String file, String cshFilePath, String fileName) {
try{
SFTPUtil sftpUtil = new SFTPUtil();
sftpUtil.login(username, password,ip,port);
InputStream inputStream = new FileInputStream(file);
sftpUtil.upload(cshFilePath,fileName,inputStream);
sftpUtil.logout();
}catch (Exception e){
e.printStackTrace();
}
}
}