.convertBodyTo(String.class)

I'm not sure if that will trigger the read of the file by itself as I
usually don't process them this way but see if putting that after the
from() causes it to load and then also log it.  The logger may be smart
enough when it sees the body is a file to load it but I don't know that
without looking at the code.

On Thu, Aug 18, 2016 at 2:20 PM, Mark <elihusma...@gmail.com> wrote:

> but then why would .log("${body}") print out the contents of the file?
>
>
> On Thu, Aug 18, 2016 at 3:13 PM, Brad Johnson <
> brad.john...@mediadriver.com>
> wrote:
>
> > That makes some sense as I believe what you're getting there is the
> handle
> > to the GenericFile object and not the contents itself. You probably have
> to
> > put a transform/simple to get the contents but I don't recall off the top
> > of my head.
> >
> > On Thu, Aug 18, 2016 at 2:00 PM, Mark <elihusma...@gmail.com> wrote:
> >
> > > Actually, it is working when I use .log("${body}").  It prints out the
> > > contents of the file.
> > >
> > > When I was calling .to("log:FILE") it was not printing the file
> contents,
> > > but I think I was reading the log statement incorrectly.
> > >
> > > What is strange is that the test app that makes the HTTP GET command
> only
> > > gets back absolute filename in the response body.
> > >
> > >
> > >
> > >
> > > On Thu, Aug 18, 2016 at 2:51 PM, Brad Johnson <
> > > brad.john...@mediadriver.com>
> > > wrote:
> > >
> > > > Are you getting any errors?  How are you testing it?
> > > >
> > > > The reason I ask is are you sure that it is finding the file at that
> > > > location?  Are you doing this as a test stub to deploy for others to
> > use
> > > or
> > > > is this something you want to test during unit tests only?  You can
> use
> > > > mocks or other mechanism for that. If you put some .log("${body}")
> > before
> > > > and after that .from what do you see?
> > > >
> > > > Brad
> > > >
> > > > On Thu, Aug 18, 2016 at 1:33 PM, Mark <elihusma...@gmail.com> wrote:
> > > >
> > > > > I want to be able to simulate a system that I'm integrating with.
> > I'd
> > > > like
> > > > > a route to return the contents of a file in a REST DSL route.  Is
> it
> > > > > possible to do this in Camel?  This is what I'd like to do:
> > > > >
> > > > > restConfiguration()
> > > > >    .component("jetty")
> > > > >    .host("localhost")
> > > > >    .port(1234)
> > > > >    .bindingMode(RestBindingMode.off);
> > > > >
> > > > >   rest().path("/mystuff")
> > > > >        .get("/testing").bindingMode(RestBindingMode.json)
> > > > >   .route()
> > > > > .setHeader(Exchange.CONTENT_TYPE).constant("application/json")
> > > > >
> > > > >          <!-- set body to contents of file -->
> > > > >           ???  .from("file:myfile.json");   ???
> > > > >
> > > > > I tried adding the "from("file:myfile.json")" to my route, but the
> > > > results
> > > > > do not come back.
> > > > >
> > > >
> > >
> >
>

Reply via email to