Merge branch 'master' of 47.110.11.213:BY_BE_team/plat2-eladmin into master
Conflicts: eladmin-system/src/main/java/me/zhengjie/modules/uploadnew/httpRequest/HttpClient.java eladmin-system/src/main/java/me/zhengjie/modules/uploadnew/task/TransFormDataTask.javamaster
commit
e5210d4df1
@ -1,42 +0,0 @@
|
||||
package me.zhengjie.modules.uploadnew.httpRequest;
|
||||
|
||||
import java.security.cert.CertificateException;
|
||||
import java.security.cert.X509Certificate;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.TrustManager;
|
||||
import javax.net.ssl.X509TrustManager;
|
||||
|
||||
import org.apache.http.conn.ClientConnectionManager;
|
||||
import org.apache.http.conn.scheme.Scheme;
|
||||
import org.apache.http.conn.scheme.SchemeRegistry;
|
||||
import org.apache.http.conn.ssl.SSLSocketFactory;
|
||||
import org.apache.http.impl.client.DefaultHttpClient;
|
||||
|
||||
//用于进行Https请求的HttpClient
|
||||
public class SSLClient extends DefaultHttpClient {
|
||||
public SSLClient() throws Exception {
|
||||
super();
|
||||
SSLContext ctx = SSLContext.getInstance("TLS");
|
||||
X509TrustManager tm = new X509TrustManager() {
|
||||
@Override
|
||||
public void checkClientTrusted(X509Certificate[] chain,
|
||||
String authType) throws CertificateException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkServerTrusted(X509Certificate[] chain,
|
||||
String authType) throws CertificateException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public X509Certificate[] getAcceptedIssuers() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
ctx.init(null, new TrustManager[]{tm}, null);
|
||||
SSLSocketFactory ssf = new SSLSocketFactory(ctx, SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
|
||||
ClientConnectionManager ccm = this.getConnectionManager();
|
||||
SchemeRegistry sr = ccm.getSchemeRegistry();
|
||||
sr.register(new Scheme("https", 443, ssf));
|
||||
}
|
||||
}
|
@ -0,0 +1,94 @@
|
||||
package me.zhengjie.modules.uploadnew.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.system.OsInfo;
|
||||
import cn.hutool.system.SystemUtil;
|
||||
import me.zhengjie.utils.FileUtil;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* @author wjt
|
||||
* @date 2021/8/6
|
||||
*/
|
||||
@Service
|
||||
public class BuildPathUtils {
|
||||
|
||||
/**
|
||||
* 远程上传临时存放文件地址 - linux环境
|
||||
*/
|
||||
@Value("${remote.link.file-base-path-linux}")
|
||||
private String fileBasePathLinux;
|
||||
|
||||
/**
|
||||
* 远程上传临时存放文件地址 - linux环境
|
||||
*/
|
||||
@Value("${remote.link.file-base-path-windows}")
|
||||
private String fileBasePathWindows;
|
||||
|
||||
/**
|
||||
* 远程上传临时存放文件地址 - linux环境
|
||||
*/
|
||||
@Value("${remote.link.file-base-path-mac}")
|
||||
private String fileBasePathMac;
|
||||
|
||||
/**
|
||||
* 构建文件上传保存路径
|
||||
*/
|
||||
public String buildFilePath() {
|
||||
// 获取环境配置信息
|
||||
OsInfo osInfo = SystemUtil.getOsInfo();
|
||||
// 定义的时间格式
|
||||
String timeFormate = DateUtil.today();
|
||||
|
||||
String dirPath;
|
||||
if (osInfo.isWindows()) {
|
||||
dirPath = fileBasePathWindows + timeFormate;
|
||||
FileUtil.mkdir(new File(dirPath));
|
||||
// 构建存储文件
|
||||
return dirPath;
|
||||
} else if (osInfo.isLinux()) {
|
||||
dirPath = fileBasePathLinux + timeFormate;
|
||||
FileUtil.mkdir(new File(dirPath));
|
||||
// 构建存储文件
|
||||
return dirPath;
|
||||
} else if (osInfo.isMac()) {
|
||||
|
||||
dirPath = fileBasePathMac + timeFormate;
|
||||
FileUtil.mkdir(new File(dirPath));
|
||||
// 构建存储文件
|
||||
return dirPath;
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建文件上传保存路径
|
||||
*/
|
||||
public String buildFileOosPath(String subFixFile) {
|
||||
OsInfo osInfo = SystemUtil.getOsInfo();
|
||||
String timeFormate = DateUtil.now() + "" + (Math.random() * 9 + 1) * 10000 + "." + subFixFile;
|
||||
String dirPath;
|
||||
if (osInfo.isWindows()) {
|
||||
dirPath = fileBasePathWindows + timeFormate;
|
||||
FileUtil.mkdir(new File(dirPath));
|
||||
// 构建存储文件
|
||||
return dirPath;
|
||||
} else if (osInfo.isLinux()) {
|
||||
dirPath = fileBasePathLinux + timeFormate;
|
||||
FileUtil.mkdir(new File(dirPath));
|
||||
// 构建存储文件
|
||||
return dirPath;
|
||||
} else if (osInfo.isMac()) {
|
||||
dirPath = fileBasePathMac + timeFormate;
|
||||
FileUtil.mkdir(new File(dirPath));
|
||||
// 构建存储文件
|
||||
return dirPath;
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue