This commit is contained in:
2026-08-08 10:31:44 +08:00
parent ced35f1600
commit 2644718b5f
32 changed files with 9710 additions and 31 deletions
@@ -101,12 +101,18 @@ public class LocalQualificationStorage {
}
public Resource load(long tenantId, String fileName) {
if (!fileName.matches("[0-9a-fA-F-]{36}\\.(jpg|png|pdf)")) throw new BizException("Invalid file name");
if (fileName == null || !fileName.matches("[0-9a-fA-F-]{36}\\.(jpg|png|pdf)")) {
throw fileNotFound();
}
Path directory = tenantDirectory(tenantId);
Path target = directory.resolve(fileName).normalize();
if (!target.startsWith(directory) || !Files.isRegularFile(target)) throw new BizException("File not found");
if (!target.startsWith(directory) || !Files.isRegularFile(target)) throw fileNotFound();
try { return new UrlResource(target.toUri()); }
catch (Exception exception) { throw new BizException("File not found"); }
catch (Exception exception) { throw fileNotFound(); }
}
private BizException fileNotFound() {
return new BizException(ResultCode.NOT_FOUND, "File not found");
}
public void delete(StoredFile file) {