You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by AnujK <re...@gmail.com> on 2011/07/21 09:36:18 UTC

SFTP rename of a file

Our use case calls for renaming a file after we have SFTPed over the file,
and finished processing.

We have one route defined for from("sftp://"...).to("..) and it downloads
the file, where we process it.

Now, I need to rename the above downloaded file in another route.

What is the best way to do a SFTP rename operation via camel? 

I assume the
from("sftp.//..fileName=fileA").to("sftp../fileName=file.A.rename") shall
work? Is this a correct way to rename a file remotely. Does the from and to
end point use the same FTP session internally or does it create 2 FTP
sessions?

Any help is appreciated.

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

Re: SFTP rename of a file

Posted by Claus Ibsen <cl...@gmail.com>.
On Thu, Jul 21, 2011 at 7:26 PM, AnujK <re...@gmail.com> wrote:
> Thanks!.
>
> So, how can we just rename the file programmatically.
>
> I am using ProducerTemplate to execute a 'move' command but it has no
> effect.
>
> producerTemplate.sendBodyAndHeader("sftp://127.0.0.1?binary=true&username=test&password=test&move=.camel&fileName=test.gzip",
>                "test.gzip", Exchange.FILE_NAME_ONLY, "test.gzip");
>
> I would like the file test.gzip to be renamed to test.gzip.camel.
>

That is because its a producer, so it sends (uploads) a file to a FTP server.
Its the consumer (which downloads) the file from the FTP server, that
after the download, can move the file.

For that you need to use the consumer template instead.

You can possible also programmatically issue a move (rename)
operation. The FtpEndpoint ought you to be abel to access the
FtpOperations where you can issues these commands.



> Our use case calls for invoking the above code multiple times for all the
> files that we have processed
>
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/SFTP-rename-of-a-file-tp4618433p4620350.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Re: SFTP rename of a file

Posted by AnujK <re...@gmail.com>.
Thanks!.

So, how can we just rename the file programmatically.

I am using ProducerTemplate to execute a 'move' command but it has no
effect.

producerTemplate.sendBodyAndHeader("sftp://127.0.0.1?binary=true&username=test&password=test&move=.camel&fileName=test.gzip", 
                "test.gzip", Exchange.FILE_NAME_ONLY, "test.gzip");

I would like the file test.gzip to be renamed to test.gzip.camel. 

Our use case calls for invoking the above code multiple times for all the
files that we have processed


        


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

Re: SFTP rename of a file

Posted by Claus Ibsen <cl...@gmail.com>.
On Thu, Jul 21, 2011 at 9:36 AM, AnujK <re...@gmail.com> wrote:
> Our use case calls for renaming a file after we have SFTPed over the file,
> and finished processing.
>
> We have one route defined for from("sftp://"...).to("..) and it downloads
> the file, where we process it.
>
> Now, I need to rename the above downloaded file in another route.
>
> What is the best way to do a SFTP rename operation via camel?
>
> I assume the
> from("sftp.//..fileName=fileA").to("sftp../fileName=file.A.rename") shall
> work? Is this a correct way to rename a file remotely. Does the from and to
> end point use the same FTP session internally or does it create 2 FTP
> sessions?
>
> Any help is appreciated.

The ftp component can automatic do that. The ftp component inherits
the options from the file component as it state on its wiki page.

Use the move option.
http://camel.apache.org/file2




>
> --
> View this message in context: http://camel.465427.n5.nabble.com/SFTP-rename-of-a-file-tp4618433p4618433.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/