feat(device): 新增设备截图管理功能

- 新增截图列表查询、单张删除、一键清空接口
- 上传截图时清洗文件名防路径穿越,filePath 仅存相对路径
- 截图静态资源映射禁用缓存,避免浏览器复用旧图
- 新增 ScreenshotVO 视图对象及 ScreenshotService 实现
This commit is contained in:
TongTongStudio
2026-08-06 01:42:46 +08:00
parent 9d6498872f
commit e9a1773d88
6 changed files with 177 additions and 2 deletions

View File

@@ -356,8 +356,13 @@ public class MobileController {
if (originName == null || originName.isEmpty()) {
return Result.failed("文件名无效");
}
// 清洗文件名,去除路径穿越风险(只保留纯文件名)
String safeBaseName = FilenameUtils.getName(originName);
if (safeBaseName.isEmpty()) {
return Result.failed("文件名无效");
}
String fileExtension = FilenameUtils.getExtension(originName);
String fileExtension = FilenameUtils.getExtension(safeBaseName);
String md5 = HashUtils.calculateMultipartFileMd5(file);
String sha1 = HashUtils.calculateMultipartFileSha1(file);
String sha256 = HashUtils.calculateMultipartFileSha256(file);
@@ -368,8 +373,10 @@ public class MobileController {
SnScreenshot screenshotInfo = new SnScreenshot();
screenshotInfo.setSn(sn);
// fileName 仅存纯文件名;前端访问 URL = /static/screenshot/{fileName}(由 WebMvcConfig 静态映射)
screenshotInfo.setFileName(fileName);
screenshotInfo.setFilePath(screenshotPath + fileName);
// filePath 仅存相对子目录,避免耦合绝对路径
screenshotInfo.setFilePath(FilePath.TABLET_PATH + "/" + FilePath.SCREENSHOT_PATH + "/" + fileName);
screenshotInfo.setFileSize(file.getSize());
screenshotInfo.setFileMd5(md5);
screenshotInfo.setFileSha1(sha1);