Hi,
Instead of using Form try using FormDataMultiPart:
https://jersey.dev.java.net/nonav/apidocs/latest/contribs/jersey-multipart/com/sun/jersey/multipart/FormDataMultiPart.html
FormDataMultiPart form = new FormDataMultiPart().
field("documentId", documentId).
field("file", inputStream);
String response = (String) webResource
.type(MediaType.MULTIPART_FORM_DATA)
.accept(MediaType.TEXT_PLAIN)
.post(String.class, form);
Having said that i think what you want to do is entirely reasonable
limited production of multipart form data parts that only contain
string strings and we should support that. Could you log an issue?
Thanks,
Paul.
On Feb 4, 2010, at 2:53 PM, Giuseppe Catanese wrote:
> Hi all
> this is similar to an old thread ("form multipart post "Missing
> start boundary" exception")
> https://jersey.dev.java.net/servlets/ReadMsg?list=users&msgNo=7186
> however I have a slightly different issue.
>
> If I use an html form to submit the file it works fine (the service
> receives the file and stores it
> on the file system), but if I use the client API I instead get
> javax.ws.rs.WebApplicationException:
> org.jvnet.mimepull.MIMEParsingException: Missing start boundary
>
> I am running my web app on Tomcat 5.5.28, here is my source:
>
> Resource implementation:
>
> @Path("upload")
> @POST
> @Produces("text/plain")
> @Consumes(MediaType.MULTIPART_FORM_DATA)
> public String uploadFile(
> @FormDataParam("documentId") Long documentId,
> @FormDataParam("file") FormDataContentDisposition
> formDataContentDisposition,
> @FormDataParam("file") InputStream content) {
>
> logger.debug("documentId: " + documentId);
> logger.debug("content: " + content);
> logger.debug("formDataContentDisposition.getFileName: " +
> formDataContentDisposition.getFileName());
>
> // here save the file
>
> return "ok";
> }
>
> Client implementation:
>
> public String uploadFile(Long documentId, InputStream
> inputStream) {
>
> logger.debug("documentId: " + documentId);
> logger.debug("inputStream: " + inputStream);
>
> WebResource webResource = client.resource("http://localhost:8081/dccm/rest/document/upload
> ");
>
> Form form = new Form();
> form.add("documentId", documentId);
> form.add("file", inputStream);
>
> String response = (String) webResource
> .type(MediaType.MULTIPART_FORM_DATA)
> .accept(MediaType.TEXT_PLAIN)
> .post(String.class, form);
>
> logger.debug("Web Service response: " + response);
>
> return response;
>
> }
>
> Any idea? Do I miss something that the html page instead does?
> Any help is really appreciated
>
> Tnx in advance
>
> Beppe
>