dev conver files
Test Workflow / test (push) Successful in 4s

This commit is contained in:
vladp
2026-02-26 00:27:31 +07:00
parent 45010bb79a
commit 983b5eddda
8 changed files with 172 additions and 89 deletions
@@ -255,13 +255,14 @@ public class FileEntityService {
fileEntityRepository.save(fileEntity);
}
private ImageResizeService imageResizeService;
@Transactional
public void writeProtectedFile(String id, byte[] data, String fileExt) throws IOException {
FileEntity fileEntity = fileEntityRepository.findById(id)
.orElseThrow(() -> new RuntimeException("File not found: " + id));
String extension = determineFileExtension(fileExt, fileEntity);
log.info("EXTENSION: {}", extension);
Path protectedFilePath = prepareProtectedPath(fileEntity, extension);
if (Files.exists(protectedFilePath)) {
@@ -270,6 +271,10 @@ public class FileEntityService {
Files.write(protectedFilePath, data);
if (imageResizeService.isImage(extension)) {
imageResizeService.generateSizes(fileEntity, data);
}
fileEntity.setProtectedFilePath(protectedFilePath.toString());
fileEntity.setProtectedAt(LocalDateTime.now());
fileEntity.setUpdatedAt(LocalDateTime.now());