Hi,
I am trying to get a Multipart REST service running with Wink. I am using
Wink 1.4 and Java 7.
@POST
@Consumes( MediaTypeUtils.MULTIPART_FORM_DATA )
public Response upload(BufferedInMultiPart inMultiPart) {
List<InPart> parts = inMultiPart.getParts();
...
}
But when I call the service I always get 415 Unsupported Media Type.
I test the service with the Wink Client:
public class WinkImagePublisher {
public static void main(String[] args) throws IOException {
String serviceUrl = "http://zzz/image";
File file = new File("/yyy/1727.jpg");
String fileName = file.getName();
BufferedOutMultiPart requestEntity = new BufferedOutMultiPart();
OutPart outPart = new OutPart();
outPart.setContentType("application/octet-stream; name=" +
fileName);
outPart.setBody(FileUtils.readFileToByteArray(file));
outPart.addHeader("Content-Transfer-Encoding", "binary");
outPart.addHeader("Content-Disposition", "form-data; name=\"" +
fileName + "\"; filename=\"" + fileName + "\"");
requestEntity.addPart(outPart);
String boundary = "simple boundary";
ClientResponse response = new RestClient().resource(serviceUrl)
.header("Content-Type", "multipart/form-data;
boundary=" + boundary)
.post(requestEntity);
System.out.println(response.getStatusCode());
System.out.println(response.getMessage());
}
}
Any idea what I am doing wrong?
Thanx in advance
Mihael
--
Schulz Gebäudeservice GmbH & Co. KG
Dr.-Max-Ilgner-Straße 17
32339 Espelkamp
Persönlich haftende Gesellschafterin:
Gebäudereinigung Joachim Schulz
Verwaltungsgesellschaft mbH
Telefon: +49 5772 9100 0
Telefax: +49 5772 9100 11
Email: [email protected]
Internet: www.sgbs.de
Geschäftsführer: Joachim und Dirk Schulz, Norbert Kosica
Handelsregister Bad Oeynhausen: HRA 5902, HRB 8591
UST-Id-Nr.: DE 125752702