mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-06-12 11:19:52 +08:00
uploadFirmware 上传固件接口
This commit is contained in:
@@ -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) {
|
public static void main(String[] args) {
|
||||||
String filePath = JsowellConfig.getUploadPath();
|
String filePath = JsowellConfig.getUploadPath();
|
||||||
System.out.println(filePath);
|
System.out.println(filePath);
|
||||||
|
|||||||
@@ -130,4 +130,11 @@ public class JsowellConfig {
|
|||||||
// return getProfile() + "/upload";
|
// return getProfile() + "/upload";
|
||||||
return getProfile();
|
return getProfile();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取固件上传路径
|
||||||
|
*/
|
||||||
|
public static String getFirmwarePath() {
|
||||||
|
return getProfile() + "/firmware";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -179,7 +179,7 @@ export default {
|
|||||||
// 设置上传的请求头部
|
// 设置上传的请求头部
|
||||||
headers: { Authorization: "Bearer " + getToken() },
|
headers: { Authorization: "Bearer " + getToken() },
|
||||||
// 上传的地址
|
// 上传的地址
|
||||||
url: process.env.VUE_APP_BASE_API + "/common/upload",
|
url: process.env.VUE_APP_BASE_API + "/common/uploadFirmware",
|
||||||
// 上传的文件列表
|
// 上传的文件列表
|
||||||
fileList: []
|
fileList: []
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user