Does anyone know how to create the RestEasy client side calls to upload a file using the following two interface signatures? I'm not finding any information at all. I know how to do it using the HttpClient but I'd like to use the client proxy to keep it consistent.
@POST
@Path("/upload")
@Consumes("multipart/form-data")
public void uploadFile(MultipartFormDataInput input);
@POST
@Path("/upload2")
@Consumes("multipart/form-data")
public void uploadFile2(@MultipartForm FileUploadForm form);
Any help would be appreciated, Fredrik
With RESTEasy 3.0.X a file upload via MultipartFormData could look like this:
I spent a bunch of time looking around for an answer to this, but I finally figured out how to make it work. You need to add:
to your classpath (or whatever version of
resteasy
you are using). You then can do something of this form:The last line is just a
JUnit
test assertion; it is not needed.thermo.wav
is specified by@FormParam("file")
and is loaded here into a byte array usingGoogle Guava's
Resources class. You can create the byte array however you want.