ci: 简化本地上传配置
This commit is contained in:
@@ -536,10 +536,12 @@ public class IReportServiceImpl extends ServiceImpl<ReportDao, ReportEntity>
|
||||
String path = uploadFile + fileEntity.getSavePath();
|
||||
FileOutputStream outputStream = new FileOutputStream(path);
|
||||
// 上传方式:阿里云:alioss 华为云:hwobs
|
||||
if (uploadType.equals("hwobs")) {
|
||||
if ("hwobs".equals(uploadType)) {
|
||||
obsBootUtil.getFileFromOBS(fileEntity.getSavePath(), outputStream);
|
||||
} else if (uploadType.equals("alioss")) {
|
||||
} else if ("alioss".equals(uploadType)) {
|
||||
ossClientUtil.getFileFromOSS(fileEntity.getSavePath(), outputStream);
|
||||
} else if ("local".equals(uploadType)) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
String html = null;
|
||||
|
||||
@@ -17,49 +17,8 @@ public class LocalFileUtil {
|
||||
@Value("${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 {
|
||||
// 获取当前工作目录并拼接文件名
|
||||
String path = getPath() + File.separator + fileName;
|
||||
String path = uploadFile + File.separator + fileName;
|
||||
FileOutputStream fileOutputStream = new FileOutputStream(path);
|
||||
byte[] buffer = new byte[1024];
|
||||
int length;
|
||||
|
||||
Reference in New Issue
Block a user