camel-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Christian Mueller (JIRA)" <>
Subject [jira] Commented: (CAMEL-1913) camel-jetty - Should support multipart/form posted data in the message body better
Date Sun, 17 Jan 2010 14:20:43 GMT


Christian Mueller commented on CAMEL-1913:

Any new ideas?

In my opinion, it's not possible to put the content of the file in the body, because the user
could upload more than one file in one request. The sample from the spec is:

   Content-Type: multipart/form-data; boundary=AaB03x

   Content-Disposition: form-data; name="submit-name"

   Content-Disposition: form-data; name="files"
   Content-Type: multipart/mixed; boundary=BbC04y

   Content-Disposition: file; filename="file1.txt"
   Content-Type: text/plain

   ... contents of file1.txt ...
   Content-Disposition: file; filename="file2.gif"
   Content-Type: image/gif
   Content-Transfer-Encoding: binary

   ...contents of file2.gif...


When I try to map all of these information to the message exchange, I came to the following
The submitted form-data could be mapped into the header. We could create an attachment for
each uploaded file. The file name is mapped to the name of the attachment. The content type
is set as the content type of the attachment (which is an instance of DataHandler). This would
be result in the following sample code:

        Message in = exchange.getIn();
        in.setHeader("submit-name", "Larry");
        in.addAttachment("file1.txt", new DataHandler(new TextDataSource("file1.txt", "text/plain",
        in.addAttachment("file2.txt", new DataHandler(new ImageDataSource("file2.txt", "image/gif",

I don't know, if Camel already uses/implements some javax.activation.DataSource classes we
should use...
What do you think?


> camel-jetty - Should support multipart/form posted data in the message body better
> ----------------------------------------------------------------------------------
>                 Key: CAMEL-1913
>                 URL:
>             Project: Apache Camel
>          Issue Type: Bug
>          Components: camel-http, camel-jetty
>    Affects Versions: 2.0-M3
>            Reporter: Claus Ibsen
>             Fix For: 2.2.0
> See CAMEL-1801
> It does not work as expected as the posted data should be in the *body* and not as it
does currently stored as a message header with the body as a key and with an empty value!
> For instance sending a file using curl
> {code}
> curl -F data=@src/test/data/plain.txt http://localhost:9080/myapp/myservice
> {code}
> You want Camel to provide the file content in the body and the other as headers. But
what you get in the body is
> {code}
> ------------------------------30cc29f24df6
> Content-Disposition: form-data; name="data"; filename="plain.txt"
> Content-Type: text/plain
> Hello World
> This is the second line
> ------------------------------30cc29f24df6--
> {code}

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message