You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Richard Kettelerij <ri...@gmail.com> on 2010/12/30 17:40:51 UTC

Re: camel file :getName of file

Hi,

One option is to add a custom processor to your route that retrieves the
filename and puts it in a property.
Then you can use this property in the exec command. It should look something
like this:

from("file://entree?delete=true") .process(new Processor() {
  public void process(Exchange exchange) throws Exception {
    File file = (File) exchange.getIn().getBody(File.class);
    exchange.setProperty("pickedUpFileName", file.getName())
  }
}).to(simple("exec:c:/python25/python.exe?args=c:/python25/stepIIS/stepIIS.py 
${property.pickedUpFileName}.step -n -l 3")) 

Take a look at http://camel.apache.org/file.html under "Read from a
directory and process the message in java". 

You can probably even skip the custom processor and work directly on the
body using the simple language (or another expression language). See
http://camel.apache.org/simple.html.
-- 
View this message in context: http://camel.465427.n5.nabble.com/camel-file-getName-of-file-tp3322455p3322617.html
Sent from the Camel - Users mailing list archive at Nabble.com.

RE: camel file :getName of file

Posted by Ɓukasz Dywicki <lu...@code-house.org>.
You may also use income header named CamelFileName which contains original
file name.

In your case:
.to(simple("exec:c:/python25/python.exe?args=c:/python25/stepIIS/stepIIS.py
${in.header.CamelFileName}.step -n -l 3"))

-----Original Message-----
From: Richard Kettelerij [mailto:richardkettelerij@gmail.com] 
Sent: Thursday, December 30, 2010 5:42 PM
To: users@camel.apache.org
Subject: Re: camel file :getName of file


Also don't forget to sign up to the mailing list, your message is currently
only visible in Nabble.
-- 
View this message in context:
http://camel.465427.n5.nabble.com/camel-file-getName-of-file-tp3322455p33226
20.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: camel file :getName of file

Posted by Richard Kettelerij <ri...@gmail.com>.
Also don't forget to sign up to the mailing list, your message is currently
only visible in Nabble.
-- 
View this message in context: http://camel.465427.n5.nabble.com/camel-file-getName-of-file-tp3322455p3322620.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: camel file :getName of file

Posted by "v.detez@gmail.com" <v....@gmail.com>.
Here is the solution :

from("file://entree?delete=true")
     	.process(new Processor() {
         public void process(Exchange exchange) throws Exception {
        	 Map<String,Object> a= exchange.getIn().getHeaders();
        	 String namefile = (String)a.get("camelfilenameonly");
        	 namefile = namefile.substring(0,namefile.indexOf("."));
        	 System.out.println(namefile);
        	 String newEndpoint =
"exec:c:/python25/python.exe?args=c:/python25/stepIIS/stepIIS.py 
c:/python25/stepIIS/"+namefile+".step -n -l 3"; 
             Exchange e =
exchange.getContext().createProducerTemplate().send(newEndpoint,exchange);
             String res = e.getIn().getBody(String.class);
             System.out.println(res);
        }});

thks for your help

Valery
-- 
View this message in context: http://camel.465427.n5.nabble.com/camel-file-getName-of-file-tp3322455p3330732.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: camel file :getName of file

Posted by davsclaus <ci...@yahoo.dk>.
You need to use the recipient list pattern when the endpoint is dynamically.
So instead of to use recipientList.
http://camel.apache.org/recipient-list.html
-- 
View this message in context: http://camel.465427.n5.nabble.com/camel-file-getName-of-file-tp3322455p3327193.html
Sent from the Camel - Users mailing list archive at Nabble.com.