|
@@ -29,6 +29,9 @@ import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.io.*;
|
|
import java.io.*;
|
|
|
import java.net.URLDecoder;
|
|
import java.net.URLDecoder;
|
|
|
|
|
+import java.util.HashMap;
|
|
|
|
|
+import java.util.Map;
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* <p>
|
|
* <p>
|
|
|
* 用户表 前端控制器
|
|
* 用户表 前端控制器
|
|
@@ -42,6 +45,7 @@ import java.net.URLDecoder;
|
|
|
@RequestMapping("/sys/common")
|
|
@RequestMapping("/sys/common")
|
|
|
public class CommonController {
|
|
public class CommonController {
|
|
|
|
|
|
|
|
|
|
+
|
|
|
@Value(value = "${jeecg.path.upload}")
|
|
@Value(value = "${jeecg.path.upload}")
|
|
|
private String uploadpath;
|
|
private String uploadpath;
|
|
|
|
|
|
|
@@ -68,8 +72,9 @@ public class CommonController {
|
|
|
*/
|
|
*/
|
|
|
@PostMapping(value = "/upload")
|
|
@PostMapping(value = "/upload")
|
|
|
public Result<?> upload(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
|
public Result<?> upload(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
|
|
- Result<?> result = new Result<>();
|
|
|
|
|
|
|
+ Result<Map<?,?>> result = new Result<>();
|
|
|
String savePath = "";
|
|
String savePath = "";
|
|
|
|
|
+ Map<String, String> fileUploadLocalResult = new HashMap<>();
|
|
|
String bizPath = request.getParameter("biz");
|
|
String bizPath = request.getParameter("biz");
|
|
|
|
|
|
|
|
//LOWCOD-2580 sys/common/upload接口存在任意文件上传漏洞
|
|
//LOWCOD-2580 sys/common/upload接口存在任意文件上传漏洞
|
|
@@ -98,7 +103,9 @@ public class CommonController {
|
|
|
FileTypeFilter.fileTypeFilter(file);
|
|
FileTypeFilter.fileTypeFilter(file);
|
|
|
//update-end-author:liusq date:20221102 for: 过滤上传文件类型
|
|
//update-end-author:liusq date:20221102 for: 过滤上传文件类型
|
|
|
//update-begin-author:lvdandan date:20200928 for:修改JEditor编辑器本地上传
|
|
//update-begin-author:lvdandan date:20200928 for:修改JEditor编辑器本地上传
|
|
|
- savePath = this.uploadLocal(file,bizPath);
|
|
|
|
|
|
|
+ fileUploadLocalResult = this.uploadLocal(file,bizPath);
|
|
|
|
|
+// savePath = this.uploadLocal(file,bizPath);
|
|
|
|
|
+ savePath = fileUploadLocalResult.get("filePath");
|
|
|
//update-begin-author:lvdandan date:20200928 for:修改JEditor编辑器本地上传
|
|
//update-begin-author:lvdandan date:20200928 for:修改JEditor编辑器本地上传
|
|
|
/** 富文本编辑器及markdown本地上传时,采用返回链接方式
|
|
/** 富文本编辑器及markdown本地上传时,采用返回链接方式
|
|
|
//针对jeditor编辑器如何使 lcaol模式,采用 base64格式存储
|
|
//针对jeditor编辑器如何使 lcaol模式,采用 base64格式存储
|
|
@@ -118,6 +125,7 @@ public class CommonController {
|
|
|
}
|
|
}
|
|
|
if(oConvertUtils.isNotEmpty(savePath)){
|
|
if(oConvertUtils.isNotEmpty(savePath)){
|
|
|
result.setMessage(savePath);
|
|
result.setMessage(savePath);
|
|
|
|
|
+ result.setResult(fileUploadLocalResult);
|
|
|
result.setSuccess(true);
|
|
result.setSuccess(true);
|
|
|
}else {
|
|
}else {
|
|
|
result.setMessage("上传失败!");
|
|
result.setMessage("上传失败!");
|
|
@@ -132,7 +140,8 @@ public class CommonController {
|
|
|
* @param bizPath 自定义路径
|
|
* @param bizPath 自定义路径
|
|
|
* @return
|
|
* @return
|
|
|
*/
|
|
*/
|
|
|
- private String uploadLocal(MultipartFile mf,String bizPath){
|
|
|
|
|
|
|
+ private Map<String, String> uploadLocal(MultipartFile mf,String bizPath){
|
|
|
|
|
+ Map<String, String> result = new HashMap<>();
|
|
|
try {
|
|
try {
|
|
|
String ctxPath = uploadpath;
|
|
String ctxPath = uploadpath;
|
|
|
String fileName = null;
|
|
String fileName = null;
|
|
@@ -144,6 +153,7 @@ public class CommonController {
|
|
|
// 获取文件名
|
|
// 获取文件名
|
|
|
String orgName = mf.getOriginalFilename();
|
|
String orgName = mf.getOriginalFilename();
|
|
|
orgName = CommonUtils.getFileName(orgName);
|
|
orgName = CommonUtils.getFileName(orgName);
|
|
|
|
|
+ result.put("origFileName", orgName);
|
|
|
if(orgName.indexOf(SymbolConstant.SPOT)!=-1){
|
|
if(orgName.indexOf(SymbolConstant.SPOT)!=-1){
|
|
|
fileName = orgName.substring(0, orgName.lastIndexOf(".")) + "_" + System.currentTimeMillis() + orgName.substring(orgName.lastIndexOf("."));
|
|
fileName = orgName.substring(0, orgName.lastIndexOf(".")) + "_" + System.currentTimeMillis() + orgName.substring(orgName.lastIndexOf("."));
|
|
|
}else{
|
|
}else{
|
|
@@ -161,11 +171,13 @@ public class CommonController {
|
|
|
if (dbpath.contains(SymbolConstant.DOUBLE_BACKSLASH)) {
|
|
if (dbpath.contains(SymbolConstant.DOUBLE_BACKSLASH)) {
|
|
|
dbpath = dbpath.replace(SymbolConstant.DOUBLE_BACKSLASH, SymbolConstant.SINGLE_SLASH);
|
|
dbpath = dbpath.replace(SymbolConstant.DOUBLE_BACKSLASH, SymbolConstant.SINGLE_SLASH);
|
|
|
}
|
|
}
|
|
|
- return dbpath;
|
|
|
|
|
|
|
+ result.put("filePath", dbpath);
|
|
|
|
|
+// return dbpath;
|
|
|
|
|
+ return result;
|
|
|
} catch (IOException e) {
|
|
} catch (IOException e) {
|
|
|
log.error(e.getMessage(), e);
|
|
log.error(e.getMessage(), e);
|
|
|
}
|
|
}
|
|
|
- return "";
|
|
|
|
|
|
|
+ return new HashMap<>();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// @PostMapping(value = "/upload2")
|
|
// @PostMapping(value = "/upload2")
|