完善代码信息

This commit is contained in:
DESKTOP-G8BCEP0\HP 2021-09-18 13:44:45 +08:00
parent ac9a7c8840
commit aebf765b42

View File

@ -40,7 +40,7 @@ public class FileController {
* @return * @return
*/ */
@PostMapping("/uploadFileMore") @PostMapping("/uploadFileMore")
public String uploadFileMore(MultipartFile[] files){ public String uploadFileMore(MultipartFile[] files) throws Exception {
Locale locale = LocaleContextHolder.getLocale(); Locale locale = LocaleContextHolder.getLocale();
if (null == files || files.length == 0){ if (null == files || files.length == 0){
return outputEncapsulationObject(PromptMessageEnum.PARAM_NULL, "result or fileType is null", locale); return outputEncapsulationObject(PromptMessageEnum.PARAM_NULL, "result or fileType is null", locale);
@ -52,9 +52,11 @@ public class FileController {
if(m == false){ if(m == false){
return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG, "图片大小不能超过100M", locale); return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG, "图片大小不能超过100M", locale);
} }
File file1 = fileFastDfs.multipartFileToFile(file);
String dir = "fire_point"; String dir = "fire_point";
String info = fileFastDfs.uploadFile(file, dir); String info = fileFastDfs.uploadFile(file1, dir);
Map<String, String> map = getUploadInfo(info); Map<String, String> map = getUploadInfo(info);
file1.delete();
FilePath filePath = new FilePath(); FilePath filePath = new FilePath();
filePath.setFilePath(map.get("path")); filePath.setFilePath(map.get("path"));
filePath.setFileName(map.get("fileName")); filePath.setFileName(map.get("fileName"));
@ -75,7 +77,7 @@ public class FileController {
* @return * @return
*/ */
@PostMapping("/uploadFile") @PostMapping("/uploadFile")
public String uploadFile(MultipartFile file){ public String uploadFile(MultipartFile file) throws Exception {
Locale locale = LocaleContextHolder.getLocale(); Locale locale = LocaleContextHolder.getLocale();
if (null == file){ if (null == file){
return outputEncapsulationObject(PromptMessageEnum.PARAM_NULL, "result or fileType is null", locale); return outputEncapsulationObject(PromptMessageEnum.PARAM_NULL, "result or fileType is null", locale);
@ -84,9 +86,11 @@ public class FileController {
if(m == false){ if(m == false){
return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG, "图片大小不能超过100M", locale); return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG, "图片大小不能超过100M", locale);
} }
File file1 = fileFastDfs.multipartFileToFile(file);
String dir = "fire_point"; String dir = "fire_point";
String info = fileFastDfs.uploadFile(file, dir); String info = fileFastDfs.uploadFile(file1, dir);
Map<String, String> map = getUploadInfo(info); Map<String, String> map = getUploadInfo(info);
file1.delete();
FilePath filePath = new FilePath(); FilePath filePath = new FilePath();
filePath.setFilePath(map.get("path")); filePath.setFilePath(map.get("path"));
filePath.setFileName(map.get("fileName")); filePath.setFileName(map.get("fileName"));