Issue with @FormDataParam in Jersey Multipart Form-Data on AEM Cloud
Hi all,
I am working with AEM as a Cloud Service and trying to handle multipart form-data using Jersey's @FormDataParam annotation for file uploads. However, I am facing issues with this approach, and I wanted to check if anyone has encountered similar problems or can provide a solution.
Here are the details:
Environment: AEM as a Cloud Service
Library: Jersey 2.25.1(jersey-media-multipart) for handling file uploads via @FormDataParam.
Issue: The @FormDataParam annotation does not seem to work as expected in AEM Cloud. The form data, including files, is not parsed correctly, and the parameters are not being extracted.
Here’s the code I’m using:
@9556322("/upload")
public class FileUploadService {
@164372
@9556322("/file")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(MediaType.APPLICATION_JSON)
public Response uploadFile(
@FormDataParam("file") InputStream uploadedInputStream,
@FormDataParam("file") FormDataContentDisposition fileDetail,
@FormDataParam("description") String description) {String fileName = fileDetail.getFileName();
// Logic to save the file and return a response
return Response.ok("{\"message\": \"File uploaded successfully\"}").build();
}
}
Observations:
The @FormDataParam annotation is not properly extracting the form data or file content.
The server doesn’t recognize the multipart form fields as expected.
I’ve verified that the form submission is correct (using an HTML form with enctype="multipart/form-data"), but still, the parameters don’t get parsed.
Questions:
Is @FormDataParam supported in AEM Cloud? If not, is there a recommended approach for handling multipart form-data uploads in AEM Cloud using Jersey or Sling Servlets?
Are there any specific configurations or limitations in AEM Cloud that could prevent Jersey's multipart handling from working properly?
Any insights or suggestions would be greatly appreciated!
Thanks in advance.