I try to send image data to the end of the seam + RESTeasy, and when I start JBoss I get a very cryptic error. The HTTP request that I am sending has the content type multipart / form-data, which has one image / jpeg part called attachment. My maintenance method is as follows:
@POST
@Path("uploadSymptomsImage/{appointmentGUID}")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces("application/json")
public String uploadSymptomsImage( @FormParam("attachment") InputStream fileInputStream,
@PathParam("appointmentGUID") String strAppointmentGUID )
{ ...
The error I get at startup:
Caused by: java.lang.RuntimeException: Unable to find a constructor that takes a String param or a valueOf() or fromString() method for javax.ws.rs.FormParam("attachment") on public java.lang.String com....AppointmentRestService.uploadSymptomsImage(java.io.InputStream,java.lang.String) for basetype: java.io.InputStream
at org.jboss.resteasy.core.StringParameterInjector.initialize(StringParameterInjector.java:206) [:]
at org.jboss.resteasy.core.StringParameterInjector.<init>(StringParameterInjector.java:57) [:]
at org.jboss.resteasy.core.FormParamInjector.<init>(FormParamInjector.java:22) [:]
My understanding was that media types can be automatically sorted into an InputStream. I also tried java.io.File, java.io.Reader - with the same error. When I replace with [] or String byte, I get an array of zero length or null as the parameter value.
? , ?
.