2

I am using the following in my Apache Camel configuration:

<camel:route errorHandlerRef="loggingErrorHandler" id="ROUTE_ICL">

    <camel:from uri="file:{{camel.route.icl.from.file.path}}?filter=#fileFilterMAVRO&amp;initialDelay={{camel.route.from.file.initialDelay}}&amp;delay={{camel.route.from.file.delay}}&amp;useFixedDelay=true&amp;runLoggingLevel=TRACE&amp;startingDirectoryMustExist={{camel.route.from.file.startingDirectoryMustExist}}&amp;autoCreate={{camel.route.from.file.autoCreate}}&amp;maxMessagesPerPoll={{camel.route.from.file.maxMessagesPerPoll}}&amp;eagerMaxMessagesPerPoll=true&amp;delete=false&amp;readLock=idempotent&amp;readLockLoggingLevel=OFF&amp;readLockRemoveOnRollback=false&amp;readLockRemoveOnCommit=false&amp;idempotent=true&amp;idempotentKey=${file:onlyname}&amp;idempotentRepository=#iclMessageIdRepository&amp;recursive=false&amp;move={{camel.route.icl.complete.file.path}}&amp;moveFailed={{camel.route.icl.failed.file.path}}" />

    <camel:to uri="sftp://user1@ecomt199.qintra.com:22/nas/tst2/inputfiles?password=Pass1234&amp;runLoggingLevel=TRACE"/>

</camel:route>

Now, this is working. It is able to sftp my file.

Problem is I want my file to be at: /nas/tst2/inputfiles. But it is going at: /home/user1/nas/tst2/inputfiles

Now, how can I make it for going it at /nas/tst2/inputfiles? /nas/ and /home/ both are on <root>/.

The problem is changing this default /home/.

Which attribute can I use? I am not able to find or understand how to do it in Camel DSL.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Sukul Amrit
  • 75
  • 1
  • 10

3 Answers3

5

Camel indeed doesn't allow fully qualified paths in the current version. However, as long as the user has the privileges, you could use a path like this as a workaround:

../../../../../../../../this_is_the_root_folder/usr/....

You basically start with the user's directory and then go up in the tree until you reach root. You only need to make sure that you added enough ../../ to get to the root.

It is not the nicest solution, but it is simple and worked for me.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
mcode
  • 534
  • 4
  • 18
0

I don't think the best solution is in the Camel DSL. The user you use for SFTP has its root in the home directory.

I think a good solution is to configure another user in the FTP server with the correct root directory, where you want to put your files.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
anpt
  • 90
  • 8
  • That will only change the username in /home/ dir, like /home/user2/. I was looking if I could get any other idea for how to do get to the main "/" dir in xml dsl. – Sukul Amrit Aug 19 '17 at 10:09
  • https://stackoverflow.com/questions/20797819/command-to-change-the-default-home-directory-of-a-user – anpt Aug 23 '17 at 08:49
  • In camel, where are we going to do this? It says for Linux. – Sukul Amrit Aug 24 '17 at 11:23
  • You use this in you target system to repoint the home dir for the user, then it's very easy to use sftp. With better security use chroot command. – anpt Aug 24 '17 at 14:24
0

You can't. The current camel-ftp implementation specifically does not allow fully qualified paths. All paths are relative to the user's home directory.

To get around this for my project I forked the component and removed the code that strips the leading path separator character.

Paul S
  • 11
  • 3
  • 1
    Can you help me with elaborate info for how to do that? – Sukul Amrit Aug 21 '17 at 09:57
  • get the camel-ftp component from GitHub. Then comment out the use of the method org.apache.camel.component.file.remote.FtpUtils. ensureRelativeFtpDirectory. – Paul S Aug 22 '17 at 16:00