|
@@ -19,25 +19,18 @@ public class UploadController {
|
19
|
19
|
@Autowired
|
20
|
20
|
FileUtil fileUtil;
|
21
|
21
|
|
22
|
|
- public static String getFileType(MultipartFile file) throws Exception {
|
23
|
|
- String fileName = file.getOriginalFilename();
|
24
|
|
- // 通过文件名获取文件后缀,并与MIME类型映射表对比获取文件类型
|
25
|
|
- String fileSuffix = fileName.substring(fileName.lastIndexOf(".") + 1);
|
26
|
|
- // 这里可以扩展为查询MIME类型映射表
|
27
|
|
- return fileSuffix;
|
28
|
|
- }
|
29
|
22
|
|
30
|
23
|
/**
|
31
|
24
|
* 通用端上传文件
|
|
25
|
+ *
|
32
|
26
|
* @param projectId 应用Id
|
33
|
27
|
* @return
|
34
|
28
|
* @throws Exception
|
35
|
29
|
*/
|
36
|
|
- @PostMapping("/upload/cms")
|
|
30
|
+ @PostMapping("/upload/{projectId}")
|
37
|
31
|
public ResponseBean uploadAdmin(@RequestParam(value = "file") MultipartFile file,
|
38
|
|
- @PathVariable(value = "projectId") String projectId
|
39
|
|
- ) throws Exception {
|
40
|
|
- String fileType = getFileType(file);
|
|
32
|
+ @RequestParam(value = "fileType") String fileType,
|
|
33
|
+ @PathVariable(value = "projectId") String projectId) throws Exception {
|
41
|
34
|
|
42
|
35
|
Map<String, Object> res = new HashMap<>();
|
43
|
36
|
String fileName = file.getOriginalFilename();
|
|
@@ -55,9 +48,9 @@ public class UploadController {
|
55
|
48
|
* @return
|
56
|
49
|
* @throws Exception
|
57
|
50
|
*/
|
58
|
|
- @PostMapping("/upload/base64/{appid}")
|
|
51
|
+ @PostMapping("/upload/base64/{projectId}")
|
59
|
52
|
public ResponseBean uploadBase64(
|
60
|
|
- @PathVariable(value = "appid") String projectId,
|
|
53
|
+ @PathVariable(value = "projectId") String projectId,
|
61
|
54
|
@RequestParam(value = "base64") String base64,
|
62
|
55
|
@RequestParam(value = "fileName", defaultValue = "unknown.jpg") String fileName
|
63
|
56
|
) throws Exception {
|