This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I have a strange problem using zehon FTP. I am trying to upload fies to a linux server.
The file is always getting uploaded to the home folder specified in passwd file for the username + file path I specify.
How can I make it move files to the full folder path I specify instead of home folder + filepath.
This is the code. Here if the destination I want to be is "/products/data" but it creates it in
You don't say what FTP server you are accessing. For security the better FTP servers limit FTP access to the home directory (and of course it's subdirectory tree) of the user logging on. With these servers, any directory one specifies on the server is assumed relative to the login user's home directory. On the assumption that you are using one of the better FTP servers, I see two possible approaches to solving your problem -
1) create an account that has /products/data as it's home directory and then changing your code to login using the credentials of this new account.
2) put a soft link in your user's home directory pointing to /products/data and make sure the user is in a group having write access to that directory.
P.S. You really wouldn't want an arbitrary account to be able to access arbitrary directories on your system would you?
Retired horse trader.
Note: double-underline links may be advertisements automatically added by this site and are probably not endorsed by me.
Joined: Feb 19, 2009
Thanks a lot James. That helps me understand why it might be behaving like that.
Joined: Feb 19, 2009
In order to eliminate the doubt of permissions. I tried to upload the same file with Apache Commons library for FTP.
Works like a charm. I would have used the same library however they do not support SFTP.
I checked the javadoc for zehon and it does not say anything about appending root to filepath.
The implication is that that FTP server is dreadfully insecure when referenced in basic FTP mode in that, subject to the normal *nix file access limitations, it allows a client to roam all over the server but in secure mode it limits access. Besides implementing one of the solutions I proposed in my earlier post you should also disable the basic FTP mode since it is compromising the security of your server.
You seem to think that there is some action you can take in your client to overcome the access imitations in SFTP mode. If there is there shouldn't be since this would compromise security.
I guess, you might have resolved this already by now. But it may just help someone else. Zehon offers a utility client called SFTPClient.
So, what you could have done is a a utility class which has a instance variable as say ChangeRemoteDir which gets set to the dir of your choice and then calls the SFTPClient method as is.
So, it can be something like -
where remoteFilePath is the one you have already set before this call.