OSDir


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

reading multipart mime dataformat


I'm wanting to send a small set of files to a HTTP server as a POST request and have Camel handle the request.

Seems like one way of doing this is to use curl on the sending end to create the POST request and have the Camel MIME-Multipart data format [1] handle the request on the receiving end. So I set up a simple test. My camel route contains this:

    rest("/multi/")
            .produces("text/plain")
            .post()
            .route()
            .log("POSTed data\n${body}")
            .unmarshal().mimeMultipart()
            .log("${body}")
            .transform(constant("OK\n"))
            .endRest();

On the sending end I post some simple test data like this:

    curl -X POST -F name=superman -F power=flying "http://localhost:8080/path/to/multi/";

This generates a body that looks like this:

--------------------------77d51bae19fb6cc5
Content-Disposition: form-data; name="name"

Superman
--------------------------77d51bae19fb6cc5
Content-Disposition: form-data; name="power"

flying
--------------------------77d51bae19fb6cc5--


But Camel fails to handle this with this error:

javax.mail.internet.ParseException: Missing start boundary
        at javax.mail.internet.MimeMultipart.parse(MimeMultipart.java:691)
        at javax.mail.internet.MimeMultipart.getBodyPart(MimeMultipart.java:350)         at org.apache.camel.dataformat.mime.multipart.MimeMultipartDataFormat.unmarshal(MimeMultipartDataFormat.java:246)         at org.apache.camel.processor.UnmarshalProcessor.process(UnmarshalProcessor.java:69)


Any hints on how to get this working? The documentation page doesn't contain much info for reading multipart requests, only writing them :-(


[1] http://camel.apache.org/mime-multipart.html