Reputation: 25
I'm writing a route that may receive a TXT file with some parameters using a Camel Servlet Component.
According to the Camel documentation I'm supposed to have the parameter set in the header of the message.
But in the the case of a HTTP POST it seems that the header is not populated as expected.
I found that the body contains all the request, the file and the parameters.
Here is an example of content :
------WebKitFormBoundaryC9GDMXt2OAHARCZj
Content-Disposition: form-data; name="upfile"; filename="user.txt"
Content-Type: text/plain
hello world...
...
------WebKitFormBoundaryC9GDMXt2OAHARCZj
Content-Disposition: form-data; name="userdata" testtest
------WebKitFormBoundaryC9GDMXt2OAHARCZj
Content-Disposition: form-data; name="id" 12344
------WebKitFormBoundaryC9GDMXt2OAHARCZj--
Does someone know a way to get the parameters by a smart way?
Do I have to make my own parser in my processor?
Upvotes: 0
Views: 3782
Reputation: 89
In the camel we can get HTTP post parameters, I am not sure to get the Content-Disposition. if we want to get Content-Disposition, we can write own processor method. But sure can get the parameters, your mentioned body content is your uploaded files content.
from(HTTP_INBOUND_URL)
.log("The message : ${in.body}")
.doTry()
.process(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
// TODO Auto-generated method stub
String templateId = exchange.getIn().getHeader("templateId",
String.class);
}
})
Where templateId is your HTTP post parameter.
Upvotes: 1
Reputation: 99
ericg,
If you use HTTP POST, the parameters are indeed set in the message body. Maybe you should implements a processor in your route to get the parameters from the body and set them in the exchange headers if it's what you need
Best regards,
Upvotes: 1