Commit 1e0bcb6b authored by “xuhd”'s avatar “xuhd”

文件类型判断

parent 66a5d5dc
...@@ -44,7 +44,7 @@ public class FileUploadController { ...@@ -44,7 +44,7 @@ public class FileUploadController {
String fileType = originalFilename.substring(file.getOriginalFilename().lastIndexOf(".")); String fileType = originalFilename.substring(file.getOriginalFilename().lastIndexOf("."));
List<String> fileTypes = fileUploadConfig.getType(); List<String> fileTypes = fileUploadConfig.getType();
log.info("支持图片类型:" + fileTypes+",上传的图片类型:"+fileType); log.info("支持图片类型:" + fileTypes+",上传的图片类型:"+fileType);
if(!fileTypes.contains(fileType)){ if(!fileTypes.stream().anyMatch(e->e.equalsIgnoreCase(fileType))){
log.info("上传文件错误"); log.info("上传文件错误");
return Result.failed(ResultCode.FILE_TYPE_ERROR); return Result.failed(ResultCode.FILE_TYPE_ERROR);
} }
......
...@@ -36,9 +36,19 @@ file: ...@@ -36,9 +36,19 @@ file:
upload: upload:
path: E:/workspace/upload path: E:/workspace/upload
type: type:
- .JPG - .png
- .JPEG - .gif
- .jpg - .jpg
- .jpeg - .jpeg
- .png - .bmp
- .PNG - .zip
- .rar
- .7z
- .gz
- .doc
- .docx
- .xls
- .xlsx
- .pdf
- .txt
- .csv
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment