强制将HTTP替换为HTTPS

This commit is contained in:
2025-11-25 14:51:10 +08:00
parent 1e9e815314
commit bf182ebc89
4 changed files with 7 additions and 3 deletions

View File

@ -13,7 +13,7 @@ import java.net.URL;
* 设备及完整类型信息导出DTO
*
* @author: 默苍璃
* @date: 2025-11-0416:25
* @date: 2025-11-04 16:25
*/
@Data
@HeadRowHeight(20) // 表头行高

View File

@ -286,6 +286,10 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
if (deviceForm.getFile() != null) {
String fileHash = fileHashUtil.hash(deviceForm.getFile());
SysOssVo upload = ossService.updateHash(deviceForm.getFile(), fileHash);
// 强制将HTTP替换为HTTPS
if (upload.getUrl() != null && upload.getUrl().startsWith("http://")) {
upload.setUrl(upload.getUrl().replaceFirst("^http://", "https://"));
}
// 设置图片路径
deviceForm.setDevicePic(upload.getUrl());
}