I am using Jersey to upload file. I defined the method:
@POST
@Path("/upload")
@Consumes("multipart/form-data")
public Collection<Message> uploadImage(@FormDataParam("file") InputStream uploadedInputStream,
@FormDataParam("file") FormDataContentDisposition fileDetail) throws IOException {
}
And invoke the call from Jersey Client for testing:
ClientConfig cc = new DefaultClientConfig();
cc.getClasses().add(MultiPartWriter.class);
Client client = Client.create(cc);
String url = "http://localhost:8080/API/api/images/upload/150";
File f = new File("C:/Pictures/1360_435x300.jpg");
FormDataMultiPart form = new FormDataMultiPart();
form.bodyPart(new FileDataBodyPart("thumbnail", f));
String s = client.resource(url).type(MediaType.MULTIPART_FORM_DATA).accept(MediaType.APPLICATION_JSON).post(String.class, form);
However, I get:
SEVERE: Missing dependency for method public java.util.Collection ImageResource.uploadImage(java.io.InputStream,com.sun.jersey.core.header.FormDataContentDisposition) throws java.io.IOException at parameter at index 1
what is wrong?