I am trying to set up an endpoint that allows multiple file upload, along other form data. Consider this like a create product page, where you would have a couple of product images but also other information. Ideally I want to map the request to a POJO
@POST
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(MediaType.APPLICATION_JSON)
@Path("/product/create")
public Response createProduct(@MultipartForm CreateProductRequest req) {
And the POJO:
@Data
public class CreateProductRequest {
@FormParam("name")
private String name;
@FormParam("description")
private String description;
@FormParam("tags")
private List<String> tags;
@FormParam("img")
@PartType(MediaType.APPLICATION_OCTET_STREAM)
private List<InputStream> img; //Ideally I could use an object such as MultipartFile
//that would give me access to the filename and MIME type
}
But this doesn't work, I get:
java.lang.RuntimeException: RESTEASY007545: Unable to find a MessageBodyReader for media type:
image/jpeg;charset=UTF-8 and class type java.util.List
If I remove the List, it works fine.
And it seems its the same issue with List<String> tags
Which throws :
java.lang.RuntimeException: RESTEASY007545: Unable to find a MessageBodyReader for media
type: text/plain;charset=UTF-8 and class type java.util.List
I've seen workarounds using MultipartFormDataInput but i would really like to avoid that since the request obj is pretty large, and mapping it by hand would be very tedious and error prone.
I am running Java 11, Quarkus 1.11.1.Final
Many thanks!