Uploaded image for project: 'RESTEasy'
  1. RESTEasy
  2. RESTEASY-2638

resteasy-multipart with @MultipartForm does not consult ParamConverterProvider

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Explained
    • 4.5.5.Final
    • None
    • resteasy-extensions
    • None
    • Hide
      Show
      Make sure you have at least JDK-11 Clone https://github.com/tomsontom/rest-easy-mp Run mvn clean test
    • Hide

      Use "MultipartFormDataInput" and split up the elements yourself

      Show
      Use "MultipartFormDataInput" and split up the elements yourself

    Description

      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;
      }

      where IMetaData looks like this:

      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.

      Attachments

        1. 589FF2D1-D106-4CFE-A8CB-B793328499A0.png
          589FF2D1-D106-4CFE-A8CB-B793328499A0.png
          66 kB
        2. Class Diagram4.png
          Class Diagram4.png
          36 kB
        3. DDFDECA1-68E5-4B76-9FB3-833F2C418D06.png
          DDFDECA1-68E5-4B76-9FB3-833F2C418D06.png
          385 kB
        4. FE65F7C2-15A6-49BD-A251-E02F974774D1.png
          FE65F7C2-15A6-49BD-A251-E02F974774D1.png
          139 kB
        5. image-2020-07-17-15-44-10-028.png
          image-2020-07-17-15-44-10-028.png
          862 kB
        6. image-2020-07-17-15-45-58-068.png
          image-2020-07-17-15-45-58-068.png
          872 kB
        7. screenshot-1.png
          screenshot-1.png
          774 kB
        8. screenshot-2.png
          screenshot-2.png
          802 kB

        Issue Links

          Activity

            People

              weinanli Weinan Li
              tom.schindl@bestsolution.at Tom Schindl (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: