设置图片路径

This commit is contained in:
2025-09-19 09:43:52 +08:00
parent 397f227bfb
commit 3e19cd9db2

View File

@ -267,9 +267,13 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
// 处理上传的图片 // 处理上传的图片
if (deviceForm.getFile() != null) { if (deviceForm.getFile() != null) {
SysOssVo upload = ossService.upload(deviceForm.getFile());
// 设置图片路径 // 设置图片路径
deviceForm.setDevicePic(upload.getUrl()); SysOssVo oss = ossService.upload(deviceForm.getFile());
// 强制将HTTP替换为HTTPS
if (oss.getUrl() != null && oss.getUrl().startsWith("http://")) {
oss.setUrl(oss.getUrl().replaceFirst("^http://", "https://"));
}
deviceForm.setDevicePic(oss.getUrl());
} }
// 更新字段 // 更新字段