3 Replies Latest reply on Mar 8, 2013 12:44 AM by beve

    Aerogear Controller Upload Multipart Form (a file)

    iampowers

      I'm attempting to upload a image through a form using the aerogear controller. The following is what I've done (and been successful at):

       

      1. I created a new MediaType

       

      {code}public static final MediaType MULTI_PART_FORM = new MediaType("multipart/form-data", JspViewResponder.class);{code}

       

      2. I then created a custom consumer in which I implemented the <T> T unmarshall(HttpServletRequest request, Class<T> type) method to use Apache's ServletFileUpload class. It returns a List of FileItems.

       

      3. From there, I parsed through the fields to map it to a bean (a part of my data model).

       

      4. My jsp uses a simple form tag with an encoding type of 'multipart/form-data' with an input of type 'file'.

       

      I feel like there should be an easier way to do this...does anyone have a better solution?

       

      Thanks,

      Nick