Re: reading multipart mime dataformat
Hi Tom Thanks for sharing the solution and as a full example. On Fri, Jun 8, 2018 at 4:08 PM, Tim Dudgeon wrote: > Here is the example: > > https://github.com/tdudgeon/camel-cdi-servlet-example > > > On 08/06/18 09:44, Claus Ibsen wrote: >> >> Hi Tom >> >> I am afraid what we have is the docs you can find, but they are more >> up to date on github >> >> https://github.com/apache/camel/blob/master/components/camel-mail/src/main/docs/mime-multipart-dataformat.adoc >> >> If you can build an unit test - reproducer sample project you are >> welcome to log a JIRA and attach - link to that. >> Also if possible try to test with latest released version. >> >> We should try to get this fixed so it works via a plain curl command. >> >> >> On Thu, Jun 7, 2018 at 6:00 PM, Tim Dudgeon wrote: >>> >>> 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 >>> >> >> > -- Claus Ibsen - http://davsclaus.com @davsclaus Camel in Action 2: https://www.manning.com/ibsen2
Re: reading multipart mime dataformat
Here is the example: https://github.com/tdudgeon/camel-cdi-servlet-example On 08/06/18 09:44, Claus Ibsen wrote: Hi Tom I am afraid what we have is the docs you can find, but they are more up to date on github https://github.com/apache/camel/blob/master/components/camel-mail/src/main/docs/mime-multipart-dataformat.adoc If you can build an unit test - reproducer sample project you are welcome to log a JIRA and attach - link to that. Also if possible try to test with latest released version. We should try to get this fixed so it works via a plain curl command. On Thu, Jun 7, 2018 at 6:00 PM, Tim Dudgeon wrote: 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
Re: reading multipart mime dataformat
Actually I got it working. I'll post an example once I've got it sorted. Tim On 08/06/18 09:44, Claus Ibsen wrote: Hi Tom I am afraid what we have is the docs you can find, but they are more up to date on github https://github.com/apache/camel/blob/master/components/camel-mail/src/main/docs/mime-multipart-dataformat.adoc If you can build an unit test - reproducer sample project you are welcome to log a JIRA and attach - link to that. Also if possible try to test with latest released version. We should try to get this fixed so it works via a plain curl command. On Thu, Jun 7, 2018 at 6:00 PM, Tim Dudgeon wrote: 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
Re: reading multipart mime dataformat
Hi Tom I am afraid what we have is the docs you can find, but they are more up to date on github https://github.com/apache/camel/blob/master/components/camel-mail/src/main/docs/mime-multipart-dataformat.adoc If you can build an unit test - reproducer sample project you are welcome to log a JIRA and attach - link to that. Also if possible try to test with latest released version. We should try to get this fixed so it works via a plain curl command. On Thu, Jun 7, 2018 at 6:00 PM, Tim Dudgeon wrote: > 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 > -- Claus Ibsen - http://davsclaus.com @davsclaus Camel in Action 2: https://www.manning.com/ibsen2