0

When uploading .xlsx files via multipart form in Quarkus 3.10.2 (Java 17), the saved files becomes corrupted. Excel shows "We found a problem with some content" error when opening them. The files are 30-40% larger than the originals, while other file types work fine.

Key Symptoms:

  • Files appear to upload successfully
  • Saved .xlsx files are unreadable in Excel
  • File sizes increase by ~40% (e.g., 100KB → 140KB)
  • Images also affected, but text/PDF files work normally

I'm using:

  • Quarkus: 3.10.2
  • Java: Amazon Corretto 17
  • OS: Windows 11 & Linux (both affected)
  • Storage: Local filesystem (ext4/NTFS)

Code:

@POST
@Consumes(MediaType.MULTIPART_FORM_DATA)
public Response uploadExcel(@RestForm("file") FileUpload file) throws IOException {
    Path dest = Path.of("uploads", file.fileName());
    
    // DEBUG: Log file sizes
    System.out.printf("Original: %d bytes | Received: %d bytes%n",
        file.size(),
        Files.size(file.uploadedFile()));
    
    Files.copy(file.uploadedFile(), dest, StandardCopyOption.REPLACE_EXISTING);
    
    return Response.ok().build();
}
7
  • 2
    Can you make a very small example of a file that gets damaged and put the original and the bad one where we can see it? Better still compare them yourself to look for the corruption. Usual causes are when binary mode hasn't been enabled or some over zealous net nanny AV type code censors obscene words in passing documents. Translation of carriage return into cr,lf is another possible glitch. I've seen something like this with a very few correspondents that I cannot send PDFs to without them corrupting in transit (I suspect particular AV software is a factor but can't be sure). Commented May 2 at 8:06
  • 5
    File sizes increase by ~40% (e.g., 100KB → 140KB) That's the kind of thing that would happen under Base64 encoding - coincidence? Commented May 2 at 9:06
  • 1
    Are these files uploaded by another program or by a user? If user, are different forms involved? Nothing in your code explains, why only certain file types are affected. Commented May 2 at 12:18
  • @Sören The file has been uploaded by the user, via Postman. Commented May 5 at 4:39
  • @MartinBrown I believe this is not a cause for AV because I created a simple file-upload API using Spring Boot, which is working fine. The issue only occurs in the Quarkus framework. Commented May 5 at 5:08

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.