Possible bug/missing feature in resteasy-multipart
by Tom Schindl
Hi,
Before fileing a Jira-Ticket I wanted to confirm that the behavior I
describe below is really a bug in resteasy or works as designed.
While implementing REST-Services in a quarkus application we came across
the problem that when doing fileuploads who are require the use of
resteasy-multipart-provider we can not use custom converters registered
for our POJOs (well in our REST-APIs we only have interfaces).
So what's the problem if we have an REST-Endpoint like this:
> @POST
> @Produces(MediaType.TEXT_PLAIN)
> @Consumes(MediaType.MULTIPART_FORM_DATA)
> @Path("multi-interface")
> public String multiPartInterface(@MultipartForm MPDataInterface data) {
> return data.metaData.getMetaInfo();
> }
>
> public static class MPDataInterface {
> @FormParam("document")
> @PartType(MediaType.APPLICATION_OCTET_STREAM)
> public InputStream document;
>
> @FormParam("metaData")
> public IMetaData metaData;
> }
> package at.bestsolution.quarkus;
>
> public interface IMetaData {
> String getMetaInfo();
> }
The upload fails because there's not way for REST-Easy to convert from
the JSON-Encoded metaData to Java-Object (that's expected).
Because of that we register "ParamConverterProvider" [1] for those
types. This works great for @PathParam(), @QueryParam but fails for the
@MultipartForm.
From looking into the code I see no codepath leading the useage
"ParamConverterProvider", hence my question is this by design or nobody
yet came across that?
I've prepared a simple test-case sample based on quarkus [2]. You can
run that using "mvn clean test".
Tom
[1]
https://github.com/tomsontom/rest-easy-mp/blob/master/src/main/java/at/be...
[2] https://github.com/tomsontom/rest-easy-mp
4 years, 5 months