我正在使用 Jersey 上传文件。我定义了方法:
@POST
@Path("/upload")
@Consumes("multipart/form-data")
public Collection<Message> uploadImage(@FormDataParam("file") InputStream uploadedInputStream,
@FormDataParam("file") FormDataContentDisposition fileDetail) throws IOException {
}
并调用 Jersey 客户端的调用进行测试:
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);
但是,我得到:
严重:缺少方法 public java.util.Collection ImageResource.uploadImage(java.io.InputStream,com.sun.jersey.core.header.FormDataContentDisposition) 的依赖项在索引 1 处的参数处引发 java.io.IOException
怎么了?