【新增】完善固件上传
This commit is contained in:
@@ -39,14 +39,14 @@ public class FirmwareServiceImpl extends ServiceImpl<FirmwareMapper, Firmware> i
|
|||||||
@Override
|
@Override
|
||||||
public boolean uploadFile(MultipartFile file, Long id) {
|
public boolean uploadFile(MultipartFile file, Long id) {
|
||||||
try {
|
try {
|
||||||
String downloadUrl = OSSUploadUtil.uploadFile(file.getInputStream(), "/");
|
String downloadUrl = OSSUploadUtil.uploadFile(file.getInputStream(), file.getOriginalFilename());
|
||||||
Firmware firmware = getById(id);
|
Firmware firmware = getById(id);
|
||||||
|
firmware.setFirmwareSize(file.getSize());
|
||||||
firmware.setDownloadUrl(downloadUrl);
|
firmware.setDownloadUrl(downloadUrl);
|
||||||
updateById(firmware);
|
return updateById(firmware);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,11 @@
|
|||||||
# 应用服务 WEB 访问端口
|
# 应用服务 WEB 访问端口
|
||||||
server.port=8080
|
server.port=8080
|
||||||
|
|
||||||
|
# 单文件最大大小(例如:10MB,支持单位:B, KB, MB, GB)
|
||||||
|
spring.servlet.multipart.max-file-size=10MB
|
||||||
|
# 一次请求中所有文件的总大小(例如:50MB)
|
||||||
|
spring.servlet.multipart.max-request-size=50MB
|
||||||
|
|
||||||
# 数据源配置
|
# 数据源配置
|
||||||
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
|
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
|
||||||
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
||||||
|
|||||||
@@ -545,6 +545,7 @@
|
|||||||
$message.success('固件上传成功');
|
$message.success('固件上传成功');
|
||||||
this.$refs.firmwareFileRef.value = "";
|
this.$refs.firmwareFileRef.value = "";
|
||||||
this.modalInstances['uploadFileModal'].hide();
|
this.modalInstances['uploadFileModal'].hide();
|
||||||
|
this.fetchData();
|
||||||
} else {
|
} else {
|
||||||
$message.error("上传失败:" + response.data.message);
|
$message.error("上传失败:" + response.data.message);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user