camel-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Christian Mueller (JIRA)" <j...@apache.org>
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

    [ https://issues.apache.org/activemq/browse/CAMEL-1913?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=56966#action_56966
] 

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:

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

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

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

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

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

   ...contents of file2.gif...
   --BbC04y--
   --AaB03x--

{code}

When I try to map all of these information to the message exchange, I came to the following
result:
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:

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

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

Regards,
Christian

> camel-jetty - Should support multipart/form posted data in the message body better
> ----------------------------------------------------------------------------------
>
>                 Key: CAMEL-1913
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-1913
>             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.


Mime
View raw message