camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <>
Subject Re: Reading Binary Files and Passing to HTTP Component
Date Sat, 19 Jun 2010 09:46:07 GMT
On Sat, Jun 19, 2010 at 9:58 AM, Willem Jiang <> wrote:
> Hi,
> I don't think current camel-http support the multipart/form-data out of box,
> as the HttpProducer will try to turn message body into an input stream if
> the http method is POST.

Ah yeah we should most likely support FileRequestEntity and
InputStreamRequestEntity out of the box.

We should most likely do something like

If body is file based -> FileRequestEntity
If body is String based -> StringRequestEntity (only check body
instanceof String, to avoid type converting as anything can be
converted into String)
Else fallback to the InputStreamRequestEntity

I wonder for the file based that people may want to read the content
of the file and send that instead?
For that they can use the .convertBodyTo(String.class) in the DSL
before hitting the to http.
But we could also offer an option to set which request entity
preferred, just as we can do that with JMS.

> Please fill a JIRA for it , and you can write a processor to call the
> HttpClient yourself to send this kind of message.
> Willem
> Nick Heudecker wrote:
>> I have the following route:
>> from("file:{{data.dir}}/query-logs/?initialDelay=600&delete=true&delay=30000")
>>            .setHeader(Exchange.HTTP_METHOD, constant(HttpMethods.POST))
>>            .setHeader(Exchange.CONTENT_TYPE,
>> constant("multipart/form-data"))
>>            .to("http:properties:{{license.server}}/processLog/{{
>> }}");
>> The files in data.dir are ZIPs, but when they're passed to the HTTP
>> component, the file contents are converted into Strings, effectively
>> corrupting the file.  How can I maintain the byte[]?
>> I've tested the HTTP endpoint independently and it works fine, so it's
>> something between reading the file and passing it to the HTTP component.
>> I've tried PUTs and POSTs, as well as changing out the content-type.  No
>> change.
>> Thanks in advance for any suggestions.
>> -Nick

Claus Ibsen
Apache Camel Committer

Author of Camel in Action:
Open Source Integration:

View raw message