dev delete check file on disk
Test Workflow / test (push) Has been cancelled

This commit is contained in:
2026-04-21 02:59:21 +07:00
parent fdc17b8325
commit 5fc9563a4e
@@ -1,10 +1,12 @@
package ru.soune.nocopy.service.file; package ru.soune.nocopy.service.file;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import ru.soune.nocopy.entity.file.FileEntity; import ru.soune.nocopy.entity.file.FileEntity;
import ru.soune.nocopy.service.file.cloud.CloudStorageService;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import java.awt.*; import java.awt.*;
@@ -18,9 +20,13 @@ import java.util.List;
@Service @Service
@Slf4j @Slf4j
@RequiredArgsConstructor
public class ImageResizeService { public class ImageResizeService {
private final CloudStorageService cloudStorageService;
private static final int THUMBNAIL_SIZE = 150; private static final int THUMBNAIL_SIZE = 150;
private static final int MEDIUM_SIZE = 600; private static final int MEDIUM_SIZE = 600;
@Value("${file.storage.base-path}") @Value("${file.storage.base-path}")
@@ -50,11 +56,15 @@ public class ImageResizeService {
if (original.getWidth() > THUMBNAIL_SIZE) { if (original.getWidth() > THUMBNAIL_SIZE) {
String thumbPath = resizeAndSave(original, baseName + "_thumb", THUMBNAIL_SIZE); String thumbPath = resizeAndSave(original, baseName + "_thumb", THUMBNAIL_SIZE);
file.setThumbnailPath(thumbPath); file.setThumbnailPath(thumbPath);
cloudStorageService.saveFilesToStorage(file.getMimeType(), file.getFileExtension(),
thumbPath);
} }
if (original.getWidth() > MEDIUM_SIZE) { if (original.getWidth() > MEDIUM_SIZE) {
String mediumPath = resizeAndSave(original, baseName + "_medium", MEDIUM_SIZE); String mediumPath = resizeAndSave(original, baseName + "_medium", MEDIUM_SIZE);
file.setMediumPath(mediumPath); file.setMediumPath(mediumPath);
cloudStorageService.saveFilesToStorage(file.getMimeType(), file.getFileExtension(),
mediumPath);
} }
} }
} }