|
|
@@ -2,6 +2,7 @@ package com.zd.base.files.file.controller;
|
|
|
|
|
|
import com.zd.base.files.file.enums.FileEnum;
|
|
|
import com.zd.base.files.file.service.ISysFileService;
|
|
|
+import com.zd.base.files.file.utils.FileUploadUtils;
|
|
|
import com.zd.common.core.utils.file.FileUtils;
|
|
|
import com.zd.model.domain.R;
|
|
|
import com.zd.model.entity.SysFile;
|
|
|
@@ -13,6 +14,10 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
/**
|
|
|
* 文件请求处理
|
|
|
*
|
|
|
@@ -39,15 +44,8 @@ public class SysFileController {
|
|
|
}else {
|
|
|
fileSuffix = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."));
|
|
|
}
|
|
|
- String[] picSuffixList = {".jpg", ".png", ".jpeg", ".gif", ".bmp", ".ico", ".pdf", ".doc", ".docx", ".ppt", ".pptx", ".mp3", ".mp4", ".avi", ".xls", ".xlsx", ".csv", ".txt", ".apk"};
|
|
|
- boolean suffixFlag = false;
|
|
|
- for (String white_suffix : picSuffixList) {
|
|
|
- if (fileSuffix.toLowerCase().equals(white_suffix)) {
|
|
|
- suffixFlag = true;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- if (suffixFlag) {
|
|
|
+ List<String> list = Arrays.asList(".jpg", ".png", ".jpeg", ".gif", ".bmp", ".ico", ".pdf", ".doc", ".docx", ".ppt", ".pptx", ".mp3", ".mp4", ".avi", ".xls", ".xlsx", ".csv", ".txt", ".apk");
|
|
|
+ if (list.contains(fileSuffix.toLowerCase())) {
|
|
|
// 上传并返回访问地址
|
|
|
String url = sysFileService.uploadFile(file);
|
|
|
SysFile sysFile = new SysFile();
|