This commit is contained in:
@@ -149,6 +149,8 @@ public class ApiController {
|
||||
MessageCode.DUPLICATE_FILE_UPLOAD.getDescription(),
|
||||
duplicateData
|
||||
));
|
||||
}catch (FileFormatException e){
|
||||
return buildErrorResponse(uploadId, chunkNumber, e.getMessage());
|
||||
} catch (Exception e) {
|
||||
log.error("Error uploading chunk", e);
|
||||
return buildErrorResponse(uploadId, chunkNumber, "Failed to upload chunk: " + e.getMessage());
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
package ru.soune.nocopy.exception;
|
||||
|
||||
public class FileFormatException extends RuntimeException {
|
||||
public FileFormatException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
@@ -5,8 +5,6 @@ import com.vrt.fileprotection.FileProtector;
|
||||
import com.vrt.fileprotection.NoCopyCheckResult;
|
||||
import com.vrt.fileprotection.audio.AudioCheckResult;
|
||||
import com.vrt.fileprotection.documents.DocumentCheckResult;
|
||||
import com.vrt.fileprotection.image.ImageCheckResult;
|
||||
import com.vrt.fileprotection.image.ImageLocalSearch;
|
||||
import jakarta.annotation.PostConstruct;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -19,10 +17,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import ru.soune.nocopy.dto.file.UploadProgressResponse;
|
||||
import ru.soune.nocopy.entity.file.*;
|
||||
import ru.soune.nocopy.exception.ChunkSizeExceededException;
|
||||
import ru.soune.nocopy.exception.DuplicateImageException;
|
||||
import ru.soune.nocopy.exception.FileUploadException;
|
||||
import ru.soune.nocopy.exception.UploadSessionNotFoundException;
|
||||
import ru.soune.nocopy.exception.*;
|
||||
import ru.soune.nocopy.repository.FileEntityRepository;
|
||||
import ru.soune.nocopy.repository.FileUploadSessionRepository;
|
||||
import ru.soune.nocopy.repository.SimilarImageProjection;
|
||||
@@ -333,7 +328,7 @@ public class FileUploadServiceImpl implements FileUploadService {
|
||||
|
||||
sessionRepository.save(session);
|
||||
|
||||
throw new FileUploadException("Failed to upload chunk: .wav file not have RIFF header");
|
||||
throw new FileFormatException("Failed to upload chunk: .wav file not have RIFF header");
|
||||
}
|
||||
|
||||
FileProtector.Type type = "document".equals(session.getFileType()) ?
|
||||
|
||||
Reference in New Issue
Block a user