uploadFirmware 上传固件接口

This commit is contained in:
Guoqs
2024-05-17 14:44:40 +08:00
parent 5c2daff575
commit 91ee42267d
3 changed files with 30 additions and 1 deletions

View File

@@ -87,6 +87,28 @@ public class CommonController {
}
}
/**
* 通用上传请求(单个)
*/
@PostMapping("/uploadFirmware")
public AjaxResult uploadFirmware(MultipartFile file) throws Exception {
try {
// 上传文件路径
String filePath = JsowellConfig.getFirmwarePath();
// 上传并返回新文件名称
String fileName = FileUploadUtils.upload(filePath, file);
String url = serverConfig.getUrl() + fileName;
AjaxResult ajax = AjaxResult.success();
ajax.put("url", url);
ajax.put("fileName", fileName);
ajax.put("newFileName", FileUtils.getName(fileName));
ajax.put("originalFilename", file.getOriginalFilename());
return ajax;
} catch (Exception e) {
return AjaxResult.error(e.getMessage());
}
}
public static void main(String[] args) {
String filePath = JsowellConfig.getUploadPath();
System.out.println(filePath);

View File

@@ -130,4 +130,11 @@ public class JsowellConfig {
// return getProfile() + "/upload";
return getProfile();
}
/**
* 获取固件上传路径
*/
public static String getFirmwarePath() {
return getProfile() + "/firmware";
}
}

View File

@@ -179,7 +179,7 @@ export default {
// 设置上传的请求头部
headers: { Authorization: "Bearer " + getToken() },
// 上传的地址
url: process.env.VUE_APP_BASE_API + "/common/upload",
url: process.env.VUE_APP_BASE_API + "/common/uploadFirmware",
// 上传的文件列表
fileList: []
},