dev fix check file mimetype
Test Workflow / test (push) Has been cancelled

This commit is contained in:
2026-04-28 12:33:51 +07:00
parent b3d99b0c02
commit b67fb403e6
@@ -25,24 +25,15 @@ public class ImageResizeService {
private final CloudStorageService cloudStorageService; private final CloudStorageService cloudStorageService;
private static final int THUMBNAIL_SIZE = 150; private static final int THUMBNAIL_SIZE = 100;
private static final int MEDIUM_SIZE = 600; private static final int MEDIUM_SIZE = 600;
@Value("${file.storage.base-path}") @Value("${file.storage.base-path}")
private String storagePath; private String storagePath;
public boolean isImage(String extension) {
return extension != null && List.of("jpg", "jpeg", "png", "webp")
.contains(extension.toLowerCase());
}
@Transactional @Transactional
public void generateSizes(FileEntity file, byte[] data) throws IOException { public void generateSizes(FileEntity file, byte[] data) throws IOException {
if (!isImage(file.getFileExtension())) {
return;
}
try (ByteArrayInputStream bis = new ByteArrayInputStream(data)) { try (ByteArrayInputStream bis = new ByteArrayInputStream(data)) {
BufferedImage original = ImageIO.read(bis); BufferedImage original = ImageIO.read(bis);
@@ -86,17 +77,4 @@ public class ImageResizeService {
return filePath.toString(); return filePath.toString();
} }
public String getPath(FileEntity file, String size) {
if ("thumbnail".equals(size) && file.getThumbnailPath() != null) {
return file.getThumbnailPath();
}
if ("medium".equals(size) && file.getMediumPath() != null) {
return file.getMediumPath();
}
return file.getProtectedFilePath();
}
} }