Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import org.apache.camel.Exchange;
- import org.apache.camel.Processor;
- import org.apache.camel.builder.RouteBuilder;
- public class MyRouteBuilder extends RouteBuilder {
- @Override
- public void configure() throws Exception {
- from("activemq:alfresco-queue")
- .process(new Processor() {
- public void process(Exchange exchange) throws Exception {
- byte[] bytes = exchange.getIn().getBody(byte[].class);
- // All of that not working...
- // exchange.getIn().setHeader("content", bytes); gives "java.lang.IllegalAgrumentException: Request header is too large"
- // exchange.getIn().setBody(bytes, byte[].class); gives "size of content is -1"
- // exchange.getIn().setBody(bytes); gives "size of content is -1"
- // ???
- // ??? But I can print file content here
- for(int i=0; i < bytes.length; i++) {
- System.out.print((char) bytes[i]);
- }
- }
- })
- .setHeader(Exchange.HTTP_METHOD, constant("POST"))
- .setHeader(Exchange.CONTENT_TYPE, constant("multipart/form-data"))
- .to("http://vm-alfce52-31......com:8080/alfresco/s/someco/queuefileuploader?guest=true")
- .process(new Processor() {
- public void process(Exchange exchange) throws Exception {
- System.out.println("The response code is: " + exchange.getIn().getHeader(Exchange.HTTP_RESPONSE_CODE));
- }
- });
- }
- }
- // somewhere on an external resource
- Content content = request.getContent();
- long len = content.getSize() // is always == -1.
Add Comment
Please, Sign In to add comment