This commit is contained in:
Anthony Stirling
2024-05-27 22:30:25 +01:00
parent 11497f52d4
commit 32209534a0
4 changed files with 37 additions and 18 deletions

View File

@@ -176,10 +176,11 @@ public class ExtractImageScansController {
return WebResponseUtils.bytesToWebResponse(
zipBytes, outputZipFilename, MediaType.APPLICATION_OCTET_STREAM);
} if (processedImageBytes.size() == 0) {
throw new IllegalArgumentException("No images detected");
}else {
}
if (processedImageBytes.size() == 0) {
throw new IllegalArgumentException("No images detected");
} else {
// Return the processed image as a response
byte[] imageBytes = processedImageBytes.get(0);
return WebResponseUtils.bytesToWebResponse(

View File

@@ -59,18 +59,17 @@ public class RepairController {
// Read the optimized PDF file
pdfBytes = Files.readAllBytes(tempOutputFile);
// Return the optimized PDF as a response
String outputFilename =
Filenames.toSimpleFileName(inputFile.getOriginalFilename())
.replaceFirst("[.][^.]+$", "")
+ "_repaired.pdf";
return WebResponseUtils.bytesToWebResponse(pdfBytes, outputFilename);
// Return the optimized PDF as a response
String outputFilename =
Filenames.toSimpleFileName(inputFile.getOriginalFilename())
.replaceFirst("[.][^.]+$", "")
+ "_repaired.pdf";
return WebResponseUtils.bytesToWebResponse(pdfBytes, outputFilename);
} finally {
// Clean up the temporary files
Files.deleteIfExists(tempInputFile);
Files.deleteIfExists(tempOutputFile);
}
}
}