diff --git a/src/main/java/stirling/software/SPDF/controller/api/security/WatermarkController.java b/src/main/java/stirling/software/SPDF/controller/api/security/WatermarkController.java index a8271207..f5655391 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/security/WatermarkController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/security/WatermarkController.java @@ -44,8 +44,8 @@ public class WatermarkController { @Operation(summary = "Add watermark to a PDF file", description = "This endpoint adds a watermark to a given PDF file. Users can specify the watermark type (text or image), rotation, opacity, width spacer, and height spacer. Input:PDF Output:PDF Type:SISO") public ResponseEntity addWatermark( @RequestPart(required = true, value = "fileInput") @Parameter(description = "The input PDF file to add a watermark") MultipartFile pdfFile, - @RequestPart(required = true) @Parameter(description = "The watermark type (text or image)") String watermarkType, - @RequestPart(required = false) @Parameter(description = "The watermark text") String watermarkText, + @RequestParam(required = true) @Parameter(description = "The watermark type (text or image)") String watermarkType, + @RequestParam(required = false) @Parameter(description = "The watermark text") String watermarkText, @RequestPart(required = false) @Parameter(description = "The watermark image") MultipartFile watermarkImage, @RequestParam(defaultValue = "roman", name = "alphabet") @Parameter(description = "The selected alphabet", diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 06e4edec..c4118342 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -15,7 +15,10 @@ server.error.whitelabel.enabled=false server.error.include-stacktrace=always server.error.include-exception=true server.error.include-message=always -\ + +#logging.level.org.springframework.web=DEBUG + + server.servlet.session.tracking-modes=cookie server.servlet.context-path=${APP_ROOT_PATH:/} diff --git a/src/main/resources/static/js/downloader.js b/src/main/resources/static/js/downloader.js index e9abdf38..59434264 100644 --- a/src/main/resources/static/js/downloader.js +++ b/src/main/resources/static/js/downloader.js @@ -14,6 +14,13 @@ $(document).ready(function() { const url = this.action; const files = $('#fileInput-input')[0].files; const formData = new FormData(this); + + // Remove empty file entries + for (let [key, value] of formData.entries()) { + if (value instanceof File && !value.name) { + formData.delete(key); + } + } const override = $('#override').val() || ''; const originalButtonText = $('#submitBtn').text(); $('#submitBtn').text('Processing...'); @@ -159,6 +166,21 @@ async function submitMultiPdfForm(url, files) { let formData = new FormData($('form')[0]); formData.delete('fileInput'); + for (let [key, value] of formData.entries()) { + console.log(key, value); + } + + // Remove empty file entries + for (let [key, value] of formData.entries()) { + if (value instanceof File && !value.name) { + formData.delete(key); + } + } + console.log("## AFTER ## ") + for (let [key, value] of formData.entries()) { + console.log(key, value); + } + const CONCURRENCY_LIMIT = 8; const chunks = []; for (let i = 0; i < Array.from(files).length; i += CONCURRENCY_LIMIT) {