dev add new action
Test Workflow / test (push) Has been cancelled

This commit is contained in:
2026-04-22 14:23:35 +07:00
parent b723247b9c
commit da84490198
2 changed files with 13 additions and 43 deletions
@@ -22,6 +22,7 @@ import ru.soune.nocopy.repository.UserRepository;
import ru.soune.nocopy.service.file.cloud.CloudStorageService;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.file.Files;
import java.nio.file.Path;
@@ -240,11 +241,18 @@ public class FileEntityService {
String extension = determineFileExtension(fileExt, fileEntity);
Path protectedFilePath = prepareProtectedPath(fileEntity, extension);
if (Files.exists(protectedFilePath)) {
Files.delete(protectedFilePath);
}
Files.createDirectories(protectedFilePath.getParent());
try (FileChannel channel = FileChannel.open(protectedFilePath, StandardOpenOption.WRITE)) {
Files.deleteIfExists(protectedFilePath);
try (FileChannel channel = FileChannel.open(protectedFilePath,
StandardOpenOption.CREATE,
StandardOpenOption.WRITE)) {
ByteBuffer buffer = ByteBuffer.wrap(data);
while (buffer.hasRemaining()) {
channel.write(buffer);
}
channel.force(true);
}