ci: 简化本地上传配置
This commit is contained in:
@@ -61,10 +61,6 @@ swaggerLevel=0
|
|||||||
#
|
#
|
||||||
#picPath=/EPR/file/home/pic/
|
#picPath=/EPR/file/home/pic/
|
||||||
|
|
||||||
# \u672C\u5730\u6587\u4EF6\u5B58\u50A8\u8DEF\u5F84\u65B9\u5F0F jar\u5305\u8DEF\u5F84\uFF1Ajar \u5DE5\u4F5C\u76EE\u5F55\uFF1Auserdir \u56FA\u5B9A\u76EE\u5F55\uFF1Asettled
|
|
||||||
localSaveFileType=settled
|
|
||||||
#localSaveFileType=userdir
|
|
||||||
|
|
||||||
# \u672C\u5730\u5B58\u50A8\u6587\u4EF6\u7684\u78C1\u76D8\u5730\u5740
|
# \u672C\u5730\u5B58\u50A8\u6587\u4EF6\u7684\u78C1\u76D8\u5730\u5740
|
||||||
#uploadFile=D:\\work\\idea\\changan\\
|
#uploadFile=D:\\work\\idea\\changan\\
|
||||||
uploadFile=/data/DeploymentPackage/report_library/uploadfile
|
uploadFile=/data/DeploymentPackage/report_library/uploadfile
|
||||||
|
|||||||
@@ -536,10 +536,12 @@ public class IReportServiceImpl extends ServiceImpl<ReportDao, ReportEntity>
|
|||||||
String path = uploadFile + fileEntity.getSavePath();
|
String path = uploadFile + fileEntity.getSavePath();
|
||||||
FileOutputStream outputStream = new FileOutputStream(path);
|
FileOutputStream outputStream = new FileOutputStream(path);
|
||||||
// 上传方式:阿里云:alioss 华为云:hwobs
|
// 上传方式:阿里云:alioss 华为云:hwobs
|
||||||
if (uploadType.equals("hwobs")) {
|
if ("hwobs".equals(uploadType)) {
|
||||||
obsBootUtil.getFileFromOBS(fileEntity.getSavePath(), outputStream);
|
obsBootUtil.getFileFromOBS(fileEntity.getSavePath(), outputStream);
|
||||||
} else if (uploadType.equals("alioss")) {
|
} else if ("alioss".equals(uploadType)) {
|
||||||
ossClientUtil.getFileFromOSS(fileEntity.getSavePath(), outputStream);
|
ossClientUtil.getFileFromOSS(fileEntity.getSavePath(), outputStream);
|
||||||
|
} else if ("local".equals(uploadType)) {
|
||||||
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
String html = null;
|
String html = null;
|
||||||
|
|||||||
@@ -17,49 +17,8 @@ public class LocalFileUtil {
|
|||||||
@Value("${uploadFile}")
|
@Value("${uploadFile}")
|
||||||
private String uploadFile;
|
private String uploadFile;
|
||||||
|
|
||||||
@Value("${localSaveFileType}")
|
|
||||||
private String localSaveFileType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取当前Jar包的路径
|
|
||||||
* @return jar包路径
|
|
||||||
*/
|
|
||||||
private String getJarPath() throws URISyntaxException {
|
|
||||||
return new File(LocalFileUtil.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath()).getParentFile().getPath();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取当前工作目录路径
|
|
||||||
* @return 当前工作目录路径
|
|
||||||
*/
|
|
||||||
private String getUserDir() {
|
|
||||||
return System.getProperty("user.dir");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 按照配置文件里指定的方式返回对应路径
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private String getPath() {
|
|
||||||
try {
|
|
||||||
switch (localSaveFileType) {
|
|
||||||
case "userdir":
|
|
||||||
return getUserDir();
|
|
||||||
case "settled":
|
|
||||||
return uploadFile;
|
|
||||||
case "jar":
|
|
||||||
return getJarPath();
|
|
||||||
default:
|
|
||||||
}
|
|
||||||
} catch (URISyntaxException e) {
|
|
||||||
log.info("获取Jar包路径失败,返回固定路径", e);
|
|
||||||
}
|
|
||||||
return uploadFile;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void saveFile(InputStream fileInputStream, String fileName) throws IOException {
|
public void saveFile(InputStream fileInputStream, String fileName) throws IOException {
|
||||||
// 获取当前工作目录并拼接文件名
|
String path = uploadFile + File.separator + fileName;
|
||||||
String path = getPath() + File.separator + fileName;
|
|
||||||
FileOutputStream fileOutputStream = new FileOutputStream(path);
|
FileOutputStream fileOutputStream = new FileOutputStream(path);
|
||||||
byte[] buffer = new byte[1024];
|
byte[] buffer = new byte[1024];
|
||||||
int length;
|
int length;
|
||||||
|
|||||||
Reference in New Issue
Block a user