|
@@ -8,12 +8,15 @@ import java.util.*;
|
|
import com.jcraft.jsch.*;
|
|
import com.jcraft.jsch.*;
|
|
import com.jeeplus.common.bos.BOSClientUtil;
|
|
import com.jeeplus.common.bos.BOSClientUtil;
|
|
import com.jeeplus.common.config.Global;
|
|
import com.jeeplus.common.config.Global;
|
|
|
|
+import com.jeeplus.common.oss.OSSClientUtil;
|
|
import com.jeeplus.common.utils.StringUtils;
|
|
import com.jeeplus.common.utils.StringUtils;
|
|
import org.apache.commons.fileupload.util.Streams;
|
|
import org.apache.commons.fileupload.util.Streams;
|
|
import org.apache.log4j.Logger;
|
|
import org.apache.log4j.Logger;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.mock.web.MockMultipartFile;
|
|
import org.springframework.mock.web.MockMultipartFile;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import org.apache.commons.io.FileUtils;
|
|
import org.apache.commons.io.FileUtils;
|
|
|
|
|
|
@@ -36,6 +39,10 @@ public class SftpClientUtil {
|
|
private final static String directory = Global.getConfig("remoteServer.directory");
|
|
private final static String directory = Global.getConfig("remoteServer.directory");
|
|
/** 文件存储方式(0:本地服务器存储。1:云端存储) */
|
|
/** 文件存储方式(0:本地服务器存储。1:云端存储) */
|
|
private final static String uploadMode = Global.getConfig("remoteServer.uploadMode");
|
|
private final static String uploadMode = Global.getConfig("remoteServer.uploadMode");
|
|
|
|
+ @Autowired
|
|
|
|
+ private HttpServletRequest request;
|
|
|
|
+ @Autowired
|
|
|
|
+ private HttpServletResponse response;
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -355,6 +362,24 @@ public class SftpClientUtil {
|
|
in.close();
|
|
in.close();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ }else if("2".equals(uploadMode)){
|
|
|
|
+ String fileNamePath = directory +"/" + downloadFile;
|
|
|
|
+ try {
|
|
|
|
+ fileNamePath = URLDecoder.decode(fileNamePath,"UTF-8");
|
|
|
|
+ String fileName = URLEncoder.encode(fileNamePath.substring(fileNamePath.lastIndexOf("/") + 1, fileNamePath.length()),"UTF-8");
|
|
|
|
+ String key = fileNamePath.substring(1,fileNamePath.length());
|
|
|
|
+
|
|
|
|
+ //判断文件的保存路径后面是否以/结尾
|
|
|
|
+ if (!downLoadFilePath.endsWith("/")) {
|
|
|
|
+ downLoadFilePath += "/";
|
|
|
|
+ }
|
|
|
|
+ //写入文件路径字符串
|
|
|
|
+ String downFileStr = downLoadFilePath + downloadFile;
|
|
|
|
+ new OSSClientUtil().downByStreamSaveLocal(key,fileName,downFileStr);
|
|
|
|
+
|
|
|
|
+ }catch (IOException e){
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
}else{
|
|
}else{
|
|
try{
|
|
try{
|
|
String path = directory.substring(directory.indexOf("=")+1, directory.length());
|
|
String path = directory.substring(directory.indexOf("=")+1, directory.length());
|
|
@@ -400,7 +425,6 @@ public class SftpClientUtil {
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* File转MultipartFile
|
|
* File转MultipartFile
|
|
* @param file
|
|
* @param file
|