南网漏洞修复
This commit is contained in:
parent
3a8119b61b
commit
2ac4a5aae6
|
|
@ -60,7 +60,7 @@ public class SysFileController {
|
||||||
ErrorCode.ATTACHMENT_UPLOAD_FAILED.getMessage());
|
ErrorCode.ATTACHMENT_UPLOAD_FAILED.getMessage());
|
||||||
}
|
}
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
log.error(e.getMessage());
|
return AjaxResult.error(e.getMessage());
|
||||||
}
|
}
|
||||||
if (file != null && file.getId() != 0){
|
if (file != null && file.getId() != 0){
|
||||||
return AjaxResult.success(file);
|
return AjaxResult.success(file);
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,8 @@ public class SysFileServiceImpl implements SysFileService {
|
||||||
*/
|
*/
|
||||||
@Value("${file.path}")
|
@Value("${file.path}")
|
||||||
private String localFilePath;
|
private String localFilePath;
|
||||||
|
// 允许的文件格式
|
||||||
|
private static final List<String> ALLOWED_EXTENSIONS = Arrays.asList("jpg", "jpeg", "txt", "png", "pdf", "docx", "doc", "xlsx", "xls");
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private FileClient fileClient;
|
private FileClient fileClient;
|
||||||
|
|
@ -73,6 +75,11 @@ public class SysFileServiceImpl implements SysFileService {
|
||||||
HashMap<String, Object> map = getFile(req);
|
HashMap<String, Object> map = getFile(req);
|
||||||
List<MultipartFile> items = (List<MultipartFile>) map.get("filePath");
|
List<MultipartFile> items = (List<MultipartFile>) map.get("filePath");
|
||||||
MultipartFile item = items.get(0);
|
MultipartFile item = items.get(0);
|
||||||
|
// 获取文件后缀名
|
||||||
|
String fileExtension = item.getOriginalFilename().substring(item.getOriginalFilename().lastIndexOf(".") + 1);
|
||||||
|
if (!ALLOWED_EXTENSIONS.contains(fileExtension.toLowerCase())) {
|
||||||
|
throw new Exception("不支持该文件格式");
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
//String url = saveFile(request, item, photoType);
|
//String url = saveFile(request, item, photoType);
|
||||||
/*AjaxResult res = fileClient.uploadFile(item);
|
/*AjaxResult res = fileClient.uploadFile(item);
|
||||||
|
|
@ -102,6 +109,7 @@ public class SysFileServiceImpl implements SysFileService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 腾讯云文件上传
|
* 腾讯云文件上传
|
||||||
|
*
|
||||||
* @param file
|
* @param file
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue