feat: 移除ssh客户端改为本地bash
This commit is contained in:
@@ -532,25 +532,29 @@ func (s *UDMVolteIMSController) Import(c *gin.Context) {
|
||||
}
|
||||
|
||||
// 网元主机的SSH客户端
|
||||
sshClient, err := s.neInfoService.NeRunSSHClient(neInfo.NeType, neInfo.NeId)
|
||||
if err != nil {
|
||||
c.JSON(200, resp.ErrMsg(err.Error()))
|
||||
return
|
||||
}
|
||||
defer sshClient.Close()
|
||||
// 网元主机的SSH客户端进行文件传输
|
||||
sftpClient, err := sshClient.NewClientSFTP()
|
||||
if err != nil {
|
||||
c.JSON(200, resp.ErrMsg(err.Error()))
|
||||
return
|
||||
}
|
||||
defer sftpClient.Close()
|
||||
// sshClient, err := s.neInfoService.NeRunSSHClient(neInfo.NeType, neInfo.NeId)
|
||||
// if err != nil {
|
||||
// c.JSON(200, resp.ErrMsg(err.Error()))
|
||||
// return
|
||||
// }
|
||||
// defer sshClient.Close()
|
||||
// // 网元主机的SSH客户端进行文件传输
|
||||
// sftpClient, err := sshClient.NewClientSFTP()
|
||||
// if err != nil {
|
||||
// c.JSON(200, resp.ErrMsg(err.Error()))
|
||||
// return
|
||||
// }
|
||||
// defer sftpClient.Close()
|
||||
|
||||
// 本地文件
|
||||
localFilePath := file.ParseUploadFileAbsPath(body.UploadPath)
|
||||
neFilePath := fmt.Sprintf("/tmp/%s", filepath.Base(localFilePath))
|
||||
// 复制到远程
|
||||
if err = sftpClient.CopyFileLocalToRemote(localFilePath, neFilePath); err != nil {
|
||||
// if err = sftpClient.CopyFileLocalToRemote(localFilePath, neFilePath); err != nil {
|
||||
// c.JSON(200, resp.ErrMsg("error uploading file"))
|
||||
// return
|
||||
// }
|
||||
if err := file.CopyFile(localFilePath, neFilePath); err != nil {
|
||||
c.JSON(200, resp.ErrMsg("error uploading file"))
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user