我从Grails 2.5.1 400
插件中的代码库通过Jersey Multipart上传文件时获得Bad Request
,jaxrs:0.11
。
REST中的代码:
@POST
@Path("/uploadTemplate")
@Consumes(MediaType.MULTIPART_FORM_DATA)
public void uploadFile(@FormDataParam("file") InputStream uploadedInputStream,
@FormDataParam("file") FormDataContentDisposition fileDetail) {
println("Upload Template Called................................................"+uploadedInputStream)
}

来自客户的电话:
final ClientConfig config = new DefaultClientConfig();
final Client client = Client.create(config);
final WebResource resource = client.resource("http://localhost:8090/ExportService/fa/templateManager/template").path("uploadTemplate");
println("URL............................" + resource.getURI());
final File fileToUpload = new File("/home/nsubedi/TestOneSheet.xlsx");
final FormDataMultiPart multiPart = new FormDataMultiPart();
FileDataBodyPart fileDataBodyPart = new FileDataBodyPart("file", fileToUpload, MediaType.MULTIPART_FORM_DATA_TYPE);
if (fileToUpload != null) {
multiPart.bodyPart(fileDataBodyPart);
}
final ClientResponse clientResp = resource.type(MediaType.MULTIPART_FORM_DATA_TYPE).post(ClientResponse.class, multiPart);
println("Response: " + clientResp.getStatus() + " Info..........." + clientResp.getStatusInfo().getReasonPhrase());

我做了很多谷歌,在stackoverflow中找到了关于mule
更改的内容,但不知道如何。
请有人帮我。感谢。